/*
 * Copyright (C) 2022-2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>

#ifdef L2_STANDARD
#include "file_ex.h"
#endif
#include "hks_apply_permission_test_common.h"
#include "hks_attest_key_test_common.h"
#include "hks_test_adapt_for_de.h"
#include "native_huks_api.h"
#include "native_huks_type.h"
#include "hks_api.h"

using namespace testing::ext;
namespace Unittest::AttestKey {

    uint8_t cert1[] = {
    0x30, 0x82, 0x04, 0xB4, 0x30, 0x82, 0x02, 0x9C, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0x03,
    0x93, 0x06, 0x86, 0x16, 0x78, 0x0F, 0x98, 0x47, 0x08, 0xBE, 0xFC, 0x04, 0x14, 0x34, 0xCD, 0xC4,
    0xAA, 0x78, 0x60, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B,
    0x05, 0x00, 0x30, 0x47, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48,
    0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D,
    0x65, 0x6E, 0x74, 0x20, 0x53, 0x32, 0x20, 0x43, 0x41, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
    0x04, 0x0A, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x0B,
    0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x30, 0x1E, 0x17, 0x0D, 0x32,
    0x35, 0x30, 0x32, 0x32, 0x31, 0x30, 0x33, 0x33, 0x32, 0x30, 0x31, 0x5A, 0x17, 0x0D, 0x32, 0x36,
    0x30, 0x32, 0x32, 0x31, 0x30, 0x33, 0x33, 0x32, 0x30, 0x31, 0x5A, 0x30, 0x44, 0x31, 0x20, 0x30,
    0x1E, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x17, 0x79, 0x6F, 0x75, 0x72, 0x2D, 0x73, 0x65, 0x72,
    0x76, 0x69, 0x63, 0x65, 0x2D, 0x64, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x31,
    0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69,
    0x20, 0x43, 0x42, 0x47, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43,
    0x4E, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
    0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01,
    0x01, 0x00, 0xB3, 0x3C, 0xFF, 0x9D, 0x29, 0xD1, 0x03, 0xCC, 0xB6, 0xF9, 0x17, 0xB4, 0x78, 0x28,
    0xF4, 0x8E, 0x8B, 0x84, 0xA9, 0x22, 0x3E, 0xA3, 0x78, 0x86, 0x5C, 0xA8, 0x68, 0xED, 0x60, 0x2F,
    0x9E, 0x4A, 0x42, 0xF6, 0xB1, 0xB7, 0xDD, 0xDF, 0xA3, 0xBC, 0x96, 0x78, 0x5D, 0x5F, 0xAA, 0x79,
    0x22, 0x9A, 0x3D, 0x09, 0xE4, 0x9C, 0x11, 0x04, 0x98, 0x1B, 0x47, 0x13, 0x74, 0x16, 0xA4, 0xAD,
    0xA5, 0x5E, 0x2A, 0xE7, 0x32, 0x85, 0x15, 0x94, 0x12, 0xB3, 0xF5, 0x1B, 0x4A, 0x61, 0x55, 0xA9,
    0xAF, 0xC4, 0x5A, 0x57, 0x39, 0xC6, 0x7E, 0x62, 0x5F, 0x2B, 0x28, 0x11, 0xD3, 0xE6, 0x3B, 0x6E,
    0xD8, 0x52, 0x7D, 0x0A, 0x9D, 0x3D, 0x44, 0xFB, 0x60, 0x71, 0x4E, 0x04, 0x24, 0x9E, 0x61, 0xFC,
    0x1D, 0x84, 0x3B, 0xC3, 0x84, 0xD5, 0x8B, 0xAF, 0x39, 0x70, 0xD6, 0xC4, 0x48, 0x9D, 0x60, 0x1F,
    0xFB, 0x10, 0x68, 0x44, 0x9D, 0xD8, 0x34, 0xA5, 0x7E, 0xAE, 0xCE, 0x5F, 0xE5, 0x7D, 0xDC, 0x4E,
    0xB5, 0x98, 0x21, 0xB1, 0x12, 0x5D, 0x20, 0x07, 0xDB, 0xD4, 0x11, 0x33, 0xCD, 0x41, 0x9A, 0x4F,
    0x6F, 0xE7, 0xC6, 0xDC, 0x8E, 0x0E, 0xAF, 0xF1, 0x22, 0x3B, 0x94, 0xA1, 0x1E, 0x96, 0x09, 0x53,
    0x9C, 0xEC, 0xE3, 0xB7, 0xB7, 0x9B, 0xA6, 0xD8, 0xA7, 0x1D, 0x73, 0xD1, 0x6F, 0x2C, 0xB1, 0x43,
    0xF8, 0x67, 0xFB, 0x1E, 0xA7, 0x35, 0x95, 0xD5, 0xE8, 0xB4, 0x30, 0xB2, 0x9C, 0x13, 0x9F, 0x4D,
    0x6F, 0xF0, 0x92, 0x5E, 0x2C, 0xC3, 0xE2, 0x7C, 0x21, 0x34, 0xAC, 0x64, 0x4F, 0x91, 0x77, 0x8E,
    0x1C, 0x81, 0x86, 0x70, 0x94, 0x50, 0x68, 0xD4, 0xF7, 0xB1, 0x1F, 0x3A, 0x8E, 0x24, 0xCC, 0x5B,
    0x3A, 0x35, 0x62, 0x2A, 0x5A, 0xE4, 0x71, 0x85, 0x2F, 0x90, 0x5A, 0xB9, 0x72, 0x97, 0x24, 0x22,
    0x6C, 0x49, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x81, 0x9A, 0x30, 0x81, 0x97, 0x30, 0x09, 0x06,
    0x03, 0x55, 0x1D, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0B, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x04,
    0x04, 0x03, 0x02, 0x05, 0xA0, 0x30, 0x3D, 0x06, 0x03, 0x55, 0x1D, 0x11, 0x04, 0x36, 0x30, 0x34,
    0x82, 0x17, 0x79, 0x6F, 0x75, 0x72, 0x2D, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2D, 0x64,
    0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x19, 0x2A, 0x2E, 0x79, 0x6F, 0x75,
    0x72, 0x2D, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2D, 0x64, 0x6F, 0x6D, 0x61, 0x69, 0x6E,
    0x2E, 0x63, 0x6F, 0x6D, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0x45,
    0xD4, 0x3B, 0xFC, 0xB0, 0xD2, 0xC1, 0xE6, 0x4B, 0x3F, 0x61, 0xDB, 0xC3, 0xD6, 0x58, 0x0F, 0xAE,
    0x30, 0x01, 0xC6, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
    0xD9, 0xAD, 0x07, 0x5D, 0x2B, 0xF5, 0x4B, 0x3A, 0x25, 0x44, 0x8C, 0x7D, 0xA9, 0x58, 0x8D, 0xC5,
    0x44, 0x4D, 0x2B, 0xCE, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01,
    0x0B, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x21, 0x75, 0x86, 0x7F, 0x0C, 0xAB, 0xE5, 0x4C,
    0xE2, 0xE6, 0x3E, 0xF2, 0xC4, 0xCE, 0xFF, 0x8F, 0x82, 0xF5, 0xC2, 0xDD, 0xB5, 0x05, 0x4E, 0x71,
    0x27, 0xBB, 0xB3, 0x2B, 0x11, 0x1D, 0xAA, 0xB6, 0xD5, 0x80, 0x82, 0xF9, 0x06, 0xD2, 0x9F, 0x7D,
    0x8B, 0x0F, 0x6D, 0x75, 0x75, 0x25, 0x0B, 0x8D, 0x30, 0xD1, 0xA0, 0x6C, 0x2F, 0x93, 0xC2, 0x1B,
    0x40, 0x21, 0xBA, 0x52, 0x13, 0xCD, 0x93, 0xA2, 0x4A, 0x96, 0x6F, 0xA5, 0x71, 0xA5, 0x12, 0x58,
    0x6A, 0x9D, 0x5A, 0x5F, 0x3C, 0xC2, 0xF6, 0xDD, 0xB0, 0x86, 0x7C, 0x9F, 0x77, 0x6D, 0x93, 0x4F,
    0x3E, 0xDD, 0xD5, 0xF3, 0x9C, 0xFF, 0x95, 0x21, 0x13, 0xDF, 0x0D, 0xA5, 0x4E, 0xB0, 0x32, 0x34,
    0x29, 0x34, 0xB3, 0x4B, 0x0F, 0xA6, 0xF6, 0x15, 0x01, 0x6F, 0x85, 0x3F, 0xF2, 0xEB, 0xE7, 0x56,
    0x8A, 0x7E, 0x1C, 0xA5, 0xAE, 0x69, 0x18, 0xA3, 0x85, 0x05, 0x28, 0x18, 0xA8, 0xA6, 0xEF, 0x1B,
    0xC0, 0x63, 0x5C, 0x96, 0xFA, 0x0B, 0xE3, 0xD4, 0x1C, 0x84, 0x18, 0xF2, 0x3B, 0x30, 0xFB, 0xE9,
    0x10, 0x0C, 0x5C, 0xDC, 0xBE, 0x56, 0xBA, 0xBF, 0x91, 0x0B, 0x07, 0xF7, 0x45, 0xB7, 0x24, 0x97,
    0xDF, 0x17, 0x50, 0xEB, 0x4C, 0xCE, 0x68, 0x67, 0x63, 0xB3, 0x7F, 0xDF, 0x3E, 0xB0, 0xEA, 0xDF,
    0xBD, 0x6F, 0x2E, 0x3A, 0x74, 0x16, 0x92, 0xDB, 0x38, 0x64, 0x0E, 0x69, 0x68, 0x85, 0x57, 0xCE,
    0x20, 0x9D, 0xCA, 0x52, 0x21, 0xB8, 0xC4, 0x06, 0x85, 0x54, 0xCE, 0x5C, 0xDF, 0xEF, 0x80, 0x91,
    0x11, 0x00, 0xFB, 0xAD, 0xD3, 0x01, 0xB9, 0xFF, 0x43, 0x1D, 0xCB, 0x2E, 0xF0, 0x25, 0x45, 0x28,
    0x32, 0x9F, 0x79, 0x92, 0x28, 0xDB, 0x31, 0xD7, 0x8D, 0x07, 0xB8, 0x54, 0xCC, 0x4F, 0x49, 0xFD,
    0x8A, 0x16, 0x81, 0x17, 0x4D, 0x03, 0xF3, 0x4A, 0xFD, 0xAE, 0x95, 0x18, 0x37, 0x05, 0x47, 0x86,
    0x41, 0x2B, 0x10, 0x78, 0xA9, 0x77, 0x48, 0x09, 0x95, 0xC5, 0x82, 0x27, 0x06, 0x6D, 0xD5, 0xA6,
    0xD9, 0xCC, 0x78, 0xB5, 0x0B, 0xAA, 0xD8, 0x1C, 0x24, 0x82, 0xD8, 0xE8, 0x9E, 0x31, 0x12, 0x36,
    0x47, 0x95, 0xD9, 0x2D, 0xDE, 0xB0, 0xCE, 0xB9, 0xBC, 0xE8, 0x57, 0x8C, 0xA4, 0x87, 0x3B, 0x0B,
    0xDC, 0xDC, 0x42, 0x99, 0xA9, 0x7C, 0x78, 0x3D, 0x5C, 0xA1, 0x99, 0xD8, 0x7C, 0x51, 0x38, 0x8A,
    0x54, 0x73, 0x2F, 0x3A, 0x6C, 0x1B, 0x55, 0x6C, 0xA6, 0xF9, 0x01, 0x44, 0xEF, 0x2D, 0x40, 0x00,
    0x38, 0xCF, 0xEB, 0x3F, 0xD7, 0xA8, 0xFA, 0xD2, 0x41, 0x98, 0x5A, 0xBB, 0xE5, 0x1B, 0x12, 0x25,
    0xD8, 0x86, 0x31, 0x66, 0x2B, 0x6B, 0xAE, 0x6C, 0x9B, 0x78, 0xFD, 0x37, 0x56, 0xD5, 0x38, 0x49,
    0x70, 0x52, 0x5D, 0xC6, 0xC5, 0x4C, 0xCE, 0x42, 0x8C, 0x69, 0x0E, 0xE4, 0x20, 0x49, 0xC1, 0xF7,
    0xA6, 0x67, 0x9D, 0x95, 0x14, 0x7E, 0xA5, 0x9C, 0x6B, 0xA3, 0xFE, 0xA0, 0xDE, 0xA2, 0x14, 0x54,
    0x12, 0x9F, 0x09, 0xC1, 0x46, 0x6B, 0xC8, 0x00, 0x1C, 0x52, 0x0B, 0xCF, 0xBD, 0x76, 0xE0, 0x2B,
    0xF1, 0xE1, 0xD8, 0xA9, 0x7A, 0x70, 0x2D, 0x8E, 0xE9, 0x57, 0xFE, 0x97, 0x6D, 0xDF, 0x83, 0x81,
    0x56, 0x10, 0xC9, 0xC4, 0x01, 0xCE, 0x69, 0x6E, 0x1C, 0xFF, 0x93, 0x15, 0xB6, 0x7D, 0x0C, 0xD5,
    0x0C, 0x7C, 0xFC, 0x75, 0x69, 0x39, 0xE9, 0x9C, 0xCC, 0xB7, 0xAB, 0x98, 0x0B, 0x01, 0x80, 0x35,
    0xB9, 0x33, 0x19, 0xE2, 0x87, 0x09, 0x6D, 0x37, 0x23, 0x8C, 0xDA, 0x62, 0xFB, 0x0D, 0xE9, 0x57,
    0x0B, 0xE4, 0xAF, 0xAD, 0x38, 0x02, 0x41, 0x82, 0x57, 0xAC, 0xAE, 0x2B, 0x99, 0x79, 0xE5, 0xA2,
    0xC0, 0x27, 0x54, 0x6E, 0xEC, 0x47, 0x9B, 0xA3,
};

uint8_t cert2[] = {
    0x30, 0x82, 0x05, 0x7C, 0x30, 0x82, 0x03, 0x64, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0x12,
    0x42, 0xF4, 0xEA, 0xED, 0x8A, 0xBC, 0x81, 0x2F, 0x13, 0x22, 0xE5, 0x75, 0xBC, 0x2A, 0xFA, 0xDD,
    0xF2, 0xA9, 0x5B, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B,
    0x05, 0x00, 0x30, 0x47, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48,
    0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D,
    0x65, 0x6E, 0x74, 0x20, 0x53, 0x32, 0x20, 0x43, 0x41, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
    0x04, 0x0A, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x0B,
    0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x30, 0x1E, 0x17, 0x0D, 0x32,
    0x35, 0x30, 0x32, 0x32, 0x31, 0x30, 0x33, 0x33, 0x31, 0x32, 0x30, 0x5A, 0x17, 0x0D, 0x33, 0x30,
    0x30, 0x32, 0x32, 0x30, 0x30, 0x33, 0x33, 0x31, 0x32, 0x30, 0x5A, 0x30, 0x47, 0x31, 0x23, 0x30,
    0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43,
    0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x32, 0x20,
    0x43, 0x41, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0A, 0x48, 0x75, 0x61,
    0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06,
    0x13, 0x02, 0x43, 0x4E, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86,
    0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0F, 0x00, 0x30, 0x82, 0x02, 0x0A,
    0x02, 0x82, 0x02, 0x01, 0x00, 0x86, 0x7B, 0x06, 0x5F, 0x74, 0x50, 0x04, 0xB0, 0x42, 0xC0, 0x6F,
    0x6A, 0xC0, 0x5D, 0x57, 0x1F, 0xD2, 0xD8, 0x8C, 0x66, 0xDD, 0x83, 0x3B, 0x23, 0xBE, 0x90, 0x0B,
    0xC9, 0x14, 0x38, 0xF4, 0xC9, 0xF9, 0x42, 0x37, 0xA2, 0x0F, 0x65, 0x7B, 0x7F, 0x6E, 0x2C, 0x43,
    0x7E, 0xF6, 0x35, 0x67, 0x1F, 0xB6, 0x14, 0x66, 0x3D, 0x0F, 0xC3, 0x44, 0x7E, 0xC6, 0x7F, 0xE2,
    0x3A, 0x5C, 0x73, 0x04, 0x37, 0xDD, 0xF4, 0x8E, 0x11, 0x51, 0x8F, 0x50, 0x02, 0xAB, 0x9E, 0x04,
    0x56, 0x1C, 0x12, 0x6D, 0x65, 0x42, 0x33, 0x20, 0x80, 0x53, 0xE0, 0x46, 0x4E, 0x4C, 0xF9, 0x04,
    0x7F, 0xFF, 0x70, 0x47, 0xF0, 0x7D, 0x1C, 0xB8, 0x06, 0xFE, 0xA8, 0xD0, 0x7E, 0x2C, 0x7A, 0x89,
    0x61, 0x44, 0x6C, 0xEB, 0xAB, 0x2B, 0x54, 0x29, 0x55, 0x77, 0x45, 0xFC, 0xFD, 0xB2, 0x17, 0xC8,
    0x19, 0xA8, 0x96, 0x8B, 0xA3, 0x25, 0x18, 0x5D, 0x6A, 0x06, 0x64, 0x99, 0x6E, 0x46, 0xE2, 0x6F,
    0xA2, 0x69, 0x3A, 0x5D, 0xB7, 0x3B, 0x33, 0x62, 0x4E, 0xEF, 0xE3, 0x86, 0xCF, 0x0C, 0x77, 0xCF,
    0xBB, 0x92, 0xC4, 0xFA, 0x7D, 0xCC, 0x06, 0xD7, 0x2D, 0xF0, 0xB3, 0xED, 0xA3, 0x7B, 0xDC, 0x84,
    0xEF, 0x5C, 0x24, 0x4C, 0x9C, 0xFE, 0x2B, 0x90, 0x42, 0xFB, 0x38, 0x5D, 0xDF, 0xD3, 0xD0, 0xC5,
    0xD3, 0x8D, 0x12, 0x95, 0x4C, 0x5D, 0x10, 0x3D, 0x04, 0x80, 0x01, 0x4D, 0x33, 0xD3, 0x6D, 0xB6,
    0x87, 0x3C, 0xB8, 0xE7, 0x44, 0x90, 0x20, 0xF8, 0x24, 0x2C, 0x83, 0x86, 0x0A, 0xEA, 0xAD, 0xF4,
    0x3E, 0x59, 0x06, 0x5E, 0x2D, 0xF1, 0x0D, 0xAA, 0xA4, 0x83, 0xDB, 0x81, 0x0F, 0x34, 0xCF, 0xA7,
    0x78, 0x54, 0xD4, 0x3A, 0x9B, 0xA6, 0xBC, 0x5A, 0x6D, 0x3A, 0x72, 0x3F, 0x30, 0x48, 0xC5, 0x87,
    0x01, 0xE6, 0xE3, 0x7D, 0xAA, 0xBC, 0xC5, 0x02, 0x71, 0x08, 0xD9, 0xC1, 0xC3, 0xDB, 0xE6, 0xCC,
    0x40, 0x0C, 0xB9, 0x0F, 0x6F, 0x63, 0xCC, 0x19, 0x05, 0xE8, 0x61, 0x4C, 0x3D, 0xBF, 0xE3, 0x71,
    0x68, 0x8E, 0x08, 0x17, 0x96, 0x93, 0xDC, 0x32, 0x88, 0x7A, 0x8C, 0x61, 0x74, 0xB0, 0x3C, 0x75,
    0xB3, 0x9D, 0x6E, 0xB3, 0x4D, 0xCB, 0xAD, 0xF8, 0x91, 0x92, 0x80, 0x08, 0x46, 0x0C, 0xFA, 0x86,
    0xCC, 0x97, 0xDB, 0x5D, 0x73, 0x5F, 0xD7, 0xF0, 0x38, 0x96, 0x12, 0x08, 0x6F, 0x80, 0xA4, 0xDF,
    0x75, 0x7F, 0x14, 0xA7, 0x6C, 0xDE, 0xE9, 0x8E, 0x80, 0xF8, 0x33, 0x15, 0xC8, 0x9E, 0x27, 0x02,
    0x2A, 0x48, 0x80, 0xAD, 0xA3, 0x82, 0xFF, 0x42, 0x7F, 0xE6, 0x65, 0x80, 0xE9, 0xB3, 0xB8, 0xEE,
    0x8A, 0x45, 0x3F, 0x4D, 0x9A, 0x32, 0xF2, 0xFD, 0xC5, 0xC4, 0xED, 0x04, 0x98, 0xA5, 0x86, 0xFF,
    0x84, 0x83, 0xF0, 0x5F, 0x30, 0xBF, 0x87, 0xD6, 0x39, 0x44, 0x7A, 0x93, 0xFE, 0x0C, 0xD4, 0xCF,
    0x3C, 0xA6, 0x0F, 0xE3, 0x5F, 0xB3, 0xDB, 0xC6, 0x3E, 0x6B, 0xC8, 0xD9, 0xE1, 0x0D, 0x72, 0x43,
    0xAC, 0x2D, 0x5B, 0x92, 0x10, 0xA9, 0x81, 0x52, 0x1E, 0x36, 0x39, 0x5E, 0x45, 0xF5, 0xA0, 0x1A,
    0xEB, 0xB5, 0xAA, 0x4F, 0xD8, 0x7A, 0x0F, 0x38, 0x4F, 0x8D, 0xEE, 0xC5, 0xFF, 0x11, 0x0B, 0xCC,
    0x54, 0x42, 0x38, 0x50, 0x31, 0x22, 0xF9, 0x92, 0xB0, 0x22, 0x74, 0x9C, 0x2B, 0x39, 0x58, 0x36,
    0x1C, 0xD2, 0x43, 0x96, 0x65, 0x98, 0xB0, 0xAF, 0xF7, 0xE8, 0x1E, 0x09, 0xAD, 0xB5, 0xB8, 0x95,
    0xBA, 0x5F, 0x59, 0xE2, 0x14, 0x89, 0x82, 0x17, 0x70, 0x95, 0x61, 0x49, 0xEB, 0x44, 0xDB, 0x1A,
    0x72, 0xF7, 0xFC, 0x44, 0xF7, 0xA8, 0x81, 0x25, 0xEB, 0xEB, 0xE6, 0xF3, 0xEA, 0x84, 0xB0, 0x4D,
    0x43, 0xE1, 0x3F, 0x70, 0xEF, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x60, 0x30, 0x5E, 0x30, 0x0F,
    0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xFF, 0x02, 0x01, 0x00, 0x30,
    0x0B, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1D, 0x06, 0x03,
    0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xD9, 0xAD, 0x07, 0x5D, 0x2B, 0xF5, 0x4B, 0x3A, 0x25,
    0x44, 0x8C, 0x7D, 0xA9, 0x58, 0x8D, 0xC5, 0x44, 0x4D, 0x2B, 0xCE, 0x30, 0x1F, 0x06, 0x03, 0x55,
    0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x7A, 0x86, 0xAC, 0xBB, 0xCE, 0x62, 0x72, 0xDC,
    0xFA, 0x9F, 0xAA, 0xDD, 0x9B, 0xBD, 0x3A, 0x4D, 0x57, 0x21, 0xBC, 0x50, 0x30, 0x0D, 0x06, 0x09,
    0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00,
    0x6F, 0xFD, 0x6C, 0x79, 0x0B, 0xE2, 0x7B, 0x6B, 0x10, 0x15, 0xA4, 0x00, 0xB6, 0xAD, 0x07, 0x08,
    0x7C, 0xC5, 0x0E, 0x28, 0xB6, 0xD8, 0xE5, 0x07, 0xEE, 0x5D, 0x85, 0x5A, 0x15, 0x49, 0x97, 0xB0,
    0xF8, 0x15, 0xFF, 0xA5, 0x88, 0xBE, 0x45, 0x07, 0x5C, 0x04, 0xD1, 0x17, 0x53, 0x6C, 0xC2, 0xAF,
    0xEC, 0x7F, 0x6D, 0x20, 0x38, 0xA6, 0x87, 0xB4, 0x90, 0x4D, 0x0B, 0x0B, 0x06, 0x8F, 0xFE, 0x17,
    0xCC, 0xAE, 0xEE, 0xFF, 0x76, 0x2D, 0x2A, 0xA7, 0xC7, 0xFE, 0x54, 0xF8, 0xEC, 0xAB, 0x45, 0x93,
    0x60, 0x50, 0x11, 0x84, 0x2C, 0x8A, 0x12, 0x46, 0x30, 0xBB, 0x84, 0x16, 0x14, 0x94, 0x49, 0xCA,
    0xED, 0x48, 0xD1, 0xA5, 0xFF, 0xEE, 0xDB, 0xDC, 0xF4, 0xF7, 0x1E, 0xCC, 0x61, 0xA5, 0x66, 0xCD,
    0x62, 0xBC, 0x2C, 0x3C, 0xF8, 0x4C, 0x9C, 0x51, 0xB8, 0x39, 0x08, 0x77, 0xE1, 0x18, 0xA0, 0xDD,
    0x98, 0x36, 0xAE, 0x7D, 0x31, 0xFB, 0xA7, 0x30, 0xC6, 0xD7, 0x62, 0xEC, 0x25, 0x1E, 0x93, 0xF4,
    0xF7, 0xCF, 0xE0, 0x36, 0xF5, 0xBA, 0xD0, 0xEE, 0xFA, 0xF3, 0x4A, 0x4A, 0x29, 0xD2, 0x69, 0x5B,
    0x5C, 0xB3, 0x55, 0x44, 0x28, 0x03, 0x5B, 0x5D, 0x43, 0xA4, 0x69, 0x18, 0x0E, 0x45, 0x54, 0xA7,
    0xA6, 0x18, 0x99, 0x67, 0x2E, 0x42, 0x35, 0x1F, 0x9E, 0x36, 0x7A, 0x29, 0x7D, 0xD2, 0xE1, 0xCB,
    0xF8, 0x34, 0xA0, 0xC7, 0xB0, 0x41, 0xF7, 0x3C, 0xB8, 0x09, 0xE9, 0x56, 0x81, 0x15, 0x0C, 0x3A,
    0x8A, 0xB0, 0x33, 0xAD, 0xDB, 0x8A, 0x70, 0xFA, 0xB1, 0xDD, 0xEF, 0xC4, 0x3F, 0x7F, 0x11, 0x92,
    0x53, 0x28, 0xB6, 0x66, 0x29, 0x67, 0x90, 0x6A, 0xBB, 0x07, 0x39, 0x01, 0x8A, 0xCB, 0xEF, 0x15,
    0xB1, 0x2C, 0xA0, 0x6D, 0x6C, 0x45, 0xDA, 0x76, 0xDE, 0x54, 0x79, 0x8B, 0xC7, 0x30, 0x6C, 0x64,
    0xED, 0x37, 0xC9, 0x60, 0xF0, 0x8B, 0x7B, 0xB6, 0x91, 0x0C, 0x8C, 0xF4, 0x40, 0x96, 0xFE, 0x34,
    0x02, 0x1A, 0x4D, 0x06, 0x88, 0x21, 0x93, 0x1E, 0xDF, 0x78, 0x09, 0xEB, 0x48, 0x08, 0xAF, 0xA3,
    0x52, 0x72, 0x9E, 0xB0, 0x7D, 0x7C, 0x7D, 0xC1, 0x8C, 0x57, 0x95, 0x14, 0x66, 0xCC, 0xCF, 0x66,
    0xCA, 0x32, 0x38, 0xC4, 0x76, 0x5C, 0xD2, 0x39, 0x58, 0x19, 0xA2, 0x58, 0x05, 0x18, 0x77, 0xD5,
    0x77, 0xA1, 0xFF, 0x96, 0xF9, 0xA1, 0xCD, 0x9F, 0x5D, 0x39, 0x69, 0xDF, 0x93, 0xB6, 0xDD, 0x1C,
    0x20, 0x9C, 0x49, 0xB5, 0xFF, 0xB5, 0x15, 0x68, 0x1A, 0x53, 0xB9, 0x31, 0x1A, 0xC8, 0x21, 0x9B,
    0x57, 0x17, 0x46, 0xD6, 0x47, 0x44, 0x4B, 0xB3, 0x5C, 0xC6, 0xFF, 0x4A, 0x5C, 0xBC, 0x30, 0xA2,
    0x55, 0xFD, 0xA9, 0xC0, 0xEB, 0xBC, 0xC3, 0xDF, 0xB6, 0x11, 0x56, 0x1C, 0x37, 0x10, 0xB6, 0x8D,
    0xAA, 0x26, 0xF8, 0x6B, 0x33, 0xDC, 0x79, 0xD0, 0x9D, 0x24, 0x06, 0xBB, 0x7C, 0x8E, 0x8A, 0xAD,
    0x80, 0x19, 0xCC, 0xFF, 0x45, 0x16, 0xB4, 0xB6, 0x2A, 0xC3, 0xBD, 0x20, 0x5B, 0x18, 0x45, 0xE9,
    0xE5, 0x6D, 0x14, 0x88, 0x79, 0x3B, 0xB3, 0x02, 0x91, 0x95, 0x1C, 0xC2, 0x53, 0x88, 0x6A, 0xA0,
    0x5F, 0xFC, 0xBC, 0x32, 0xF6, 0x58, 0xED, 0x49, 0xBA, 0x15, 0x18, 0x2B, 0xA3, 0x33, 0xF0, 0x06,
    0xE4, 0x36, 0x00, 0xAF, 0xBA, 0xC5, 0x2B, 0x7B, 0x19, 0x1C, 0xC8, 0x87, 0x7A, 0x38, 0xF2, 0x00,
    0x23, 0x2D, 0x31, 0x73, 0x72, 0xB5, 0xE2, 0x7C, 0x84, 0x3F, 0x72, 0x6A, 0x08, 0xA3, 0x60, 0x6F,
    0xA4, 0x92, 0xF1, 0x5D, 0x1F, 0x1E, 0x46, 0x3F, 0x17, 0x76, 0x14, 0x11, 0x22, 0x77, 0xA5, 0xEB,
    0x36, 0x0A, 0xB7, 0x2F, 0x19, 0x6A, 0x95, 0x54, 0x32, 0xC5, 0xFE, 0x48, 0x0D, 0xB5, 0x79, 0x03,
};

uint8_t cert3[] = {
    0x30, 0x82, 0x05, 0x79, 0x30, 0x82, 0x03, 0x61, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0x2D,
    0xDE, 0xEF, 0x5E, 0x0B, 0x01, 0xBE, 0x47, 0xD0, 0xD4, 0x3C, 0xFA, 0x9A, 0xA5, 0x3E, 0x65, 0x10,
    0x29, 0xF4, 0x6E, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B,
    0x05, 0x00, 0x30, 0x47, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48,
    0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D,
    0x65, 0x6E, 0x74, 0x20, 0x53, 0x32, 0x20, 0x43, 0x41, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
    0x04, 0x0A, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x0B,
    0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x30, 0x1E, 0x17, 0x0D, 0x32,
    0x35, 0x30, 0x32, 0x32, 0x31, 0x30, 0x33, 0x33, 0x30, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x35,
    0x30, 0x32, 0x31, 0x39, 0x30, 0x33, 0x33, 0x30, 0x34, 0x37, 0x5A, 0x30, 0x47, 0x31, 0x23, 0x30,

    0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43,
    0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x32, 0x20,
    0x43, 0x41, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0A, 0x48, 0x75, 0x61,
    0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06,
    0x13, 0x02, 0x43, 0x4E, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86,
    0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0F, 0x00, 0x30, 0x82, 0x02, 0x0A,
    0x02, 0x82, 0x02, 0x01, 0x00, 0xC7, 0xA6, 0x25, 0xF8, 0xA8, 0xF5, 0x79, 0x83, 0x00, 0x3C, 0x34,
    0x5A, 0x01, 0x0E, 0x5F, 0xD3, 0x5C, 0xC3, 0xED, 0x64, 0xFD, 0xE5, 0x26, 0x0C, 0xBE, 0x19, 0x56,
    0xFA, 0x26, 0xDE, 0x98, 0x2D, 0x71, 0x40, 0x7E, 0x36, 0x64, 0x6D, 0x33, 0x0F, 0xF1, 0x49, 0x51,
    0x36, 0x14, 0x6A, 0x4A, 0x89, 0xD6, 0xB6, 0x26, 0x88, 0xF2, 0xA4, 0x7C, 0xF8, 0xE9, 0xB0, 0x65,

    0xBD, 0xEF, 0x6C, 0xBD, 0x2B, 0xAA, 0xC8, 0x79, 0x63, 0xF4, 0x5C, 0x70, 0x19, 0x04, 0x18, 0x7E,
    0xCE, 0x34, 0x80, 0xBB, 0xBE, 0x83, 0xC4, 0xD4, 0xC1, 0x03, 0x95, 0xB9, 0x93, 0x2A, 0x51, 0x1D,
    0x7B, 0xF4, 0xDE, 0x3B, 0xDD, 0xD2, 0xE3, 0xF4, 0xB9, 0xDE, 0xFA, 0x94, 0x2B, 0x25, 0xB9, 0xD0,
    0x91, 0xB6, 0xDA, 0x8A, 0x89, 0x7C, 0x59, 0x4F, 0xA2, 0xB0, 0x5F, 0xC1, 0xF8, 0xAF, 0xF6, 0xCA,
    0x2E, 0x8D, 0x69, 0xBA, 0xB5, 0x6A, 0x67, 0xCB, 0x00, 0x02, 0x57, 0x51, 0x69, 0x03, 0x84, 0x91,
    0x42, 0x9B, 0x05, 0xAF, 0xAF, 0x8C, 0x1F, 0xCA, 0xD1, 0xC0, 0xA8, 0xF0, 0xB8, 0xB7, 0x17, 0x85,
    0xCA, 0xBE, 0x7B, 0x18, 0xBC, 0x1B, 0xBA, 0xDE, 0x40, 0x2C, 0x43, 0x41, 0x21, 0x27, 0xAA, 0xA0,
    0xB8, 0x29, 0xA7, 0xC5, 0x3A, 0xB8, 0x11, 0x86, 0x90, 0x69, 0x4D, 0x01, 0xBF, 0xA1, 0x43, 0xBE,
    0x96, 0x60, 0x9E, 0xDD, 0x37, 0x6C, 0xE1, 0xEC, 0x2A, 0xCD, 0xF1, 0x63, 0x81, 0x43, 0x29, 0xA4,
    0x22, 0x77, 0xD3, 0xA6, 0xC1, 0xCF, 0x1C, 0xD8, 0x9B, 0x8B, 0x77, 0x8C, 0xD3, 0x29, 0x28, 0x8A,

    0x56, 0xA1, 0x1D, 0xE4, 0x29, 0x22, 0xCD, 0x78, 0xFF, 0xA2, 0x82, 0x75, 0x17, 0xEC, 0x0D, 0xE8,
    0x69, 0x1E, 0xDD, 0x30, 0xBE, 0x91, 0xBC, 0x7B, 0x8C, 0x70, 0xE1, 0x3E, 0xA8, 0x0D, 0x07, 0x95,
    0x71, 0xA5, 0x9D, 0xC0, 0xEC, 0xE1, 0x66, 0x7F, 0xA7, 0xD6, 0x5D, 0xE0, 0x1B, 0xB1, 0x3D, 0x00,
    0xCE, 0x1C, 0x61, 0x98, 0x76, 0x56, 0x67, 0xF8, 0x43, 0x6A, 0x20, 0x48, 0x80, 0xBD, 0x19, 0xDE,
    0xEB, 0x72, 0x3E, 0xF4, 0xE0, 0x41, 0x5E, 0x10, 0x05, 0x1C, 0xF8, 0x13, 0xAE, 0x01, 0x8B, 0x00,
    0xA8, 0x43, 0xE7, 0x3F, 0x62, 0xBA, 0x3B, 0x1E, 0x82, 0xEB, 0x1C, 0xF9, 0xD7, 0x1E, 0x9E, 0x0D,
    0x53, 0x16, 0x06, 0xB1, 0x87, 0x24, 0xDA, 0xF9, 0xEF, 0xC7, 0x31, 0x37, 0xE9, 0x13, 0xF4, 0x75,
    0x99, 0x69, 0x17, 0xEA, 0xB3, 0xE7, 0x17, 0xDA, 0x10, 0xF8, 0xDD, 0xFF, 0xAC, 0xC0, 0x2F, 0x70,
    0x15, 0xFC, 0x54, 0x34, 0xBE, 0x2E, 0x98, 0x51, 0xB1, 0xC6, 0x30, 0x36, 0x68, 0x74, 0x1C, 0x3D,
    0xC7, 0x1F, 0x4A, 0x0B, 0x29, 0xAA, 0xF2, 0xFA, 0x62, 0xB1, 0x05, 0xC5, 0xD6, 0xF1, 0xD5, 0xB6,

    0x1A, 0x91, 0x8C, 0xDF, 0x1F, 0xF9, 0x52, 0x9D, 0xB2, 0xD2, 0xA6, 0xDD, 0x44, 0x06, 0x1C, 0x20,
    0x3E, 0x07, 0xAE, 0x69, 0x6C, 0xD5, 0x15, 0x0C, 0xFD, 0x21, 0x57, 0xB4, 0xFF, 0x59, 0x2E, 0xD1,
    0xB3, 0xA5, 0x16, 0xE9, 0xCD, 0xCA, 0x24, 0x76, 0xD3, 0xBF, 0x14, 0xCB, 0x74, 0x32, 0xB0, 0x6A,
    0x1A, 0x7D, 0x6D, 0x21, 0x19, 0x8A, 0x97, 0x1F, 0xF7, 0xD9, 0xF3, 0x6C, 0x1A, 0x1F, 0xD6, 0x5E,
    0xDA, 0x35, 0x6A, 0x79, 0x53, 0x42, 0x4E, 0x8A, 0xBE, 0xDF, 0x90, 0x8D, 0x53, 0x00, 0xDD, 0xC7,
    0xBB, 0x1F, 0xFF, 0x71, 0xEA, 0x47, 0x7A, 0x63, 0x5C, 0x70, 0x6C, 0xED, 0x7F, 0xE1, 0x6B, 0x11,
    0x18, 0x9D, 0x3C, 0x37, 0x11, 0xD5, 0xD2, 0xAB, 0x92, 0x0E, 0xBC, 0xB3, 0x0B, 0xD0, 0x69, 0x3D,
    0x25, 0x1A, 0x4C, 0x8B, 0x3F, 0x17, 0x4D, 0x49, 0x97, 0x59, 0x08, 0x66, 0xF3, 0x40, 0x5E, 0x9F,
    0x30, 0xEB, 0xB7, 0x36, 0xD9, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x5D, 0x30, 0x5B, 0x30, 0x0C,
    0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30, 0x0B, 0x06, 0x03,

    0x55, 0x1D, 0x0F, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E,
    0x04, 0x16, 0x04, 0x14, 0x7A, 0x86, 0xAC, 0xBB, 0xCE, 0x62, 0x72, 0xDC, 0xFA, 0x9F, 0xAA, 0xDD,
    0x9B, 0xBD, 0x3A, 0x4D, 0x57, 0x21, 0xBC, 0x50, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04,
    0x18, 0x30, 0x16, 0x80, 0x14, 0x7A, 0x86, 0xAC, 0xBB, 0xCE, 0x62, 0x72, 0xDC, 0xFA, 0x9F, 0xAA,
    0xDD, 0x9B, 0xBD, 0x3A, 0x4D, 0x57, 0x21, 0xBC, 0x50, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48,
    0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x32, 0x8E, 0x4D,
    0x0E, 0x83, 0x93, 0xB0, 0x9B, 0xB9, 0xF2, 0x59, 0x80, 0x05, 0x77, 0xB8, 0xBA, 0xBF, 0x4C, 0xCF,
    0xA8, 0x71, 0x5B, 0x05, 0x3B, 0xED, 0x1E, 0x25, 0xB5, 0x16, 0x71, 0x9F, 0x3B, 0xB1, 0xEC, 0xC1,
    0x4A, 0x78, 0x26, 0x0D, 0xA7, 0x8F, 0x79, 0xBF, 0x5A, 0x9A, 0x4C, 0xE2, 0x0B, 0x2D, 0xB9, 0x20,
    0x0B, 0x44, 0x30, 0x2C, 0xE4, 0x3B, 0xBE, 0xAC, 0x04, 0x07, 0x01, 0x28, 0x52, 0x7B, 0x14, 0x3A,

    0x55, 0xAA, 0x05, 0x89, 0xB2, 0x22, 0xC9, 0xB6, 0xF1, 0xC0, 0xAE, 0xCA, 0x86, 0xE3, 0x2A, 0x94,
    0xC6, 0x67, 0xFD, 0x68, 0xE2, 0x1B, 0x96, 0x78, 0xE6, 0xB3, 0x46, 0x2E, 0xE2, 0x93, 0x1F, 0x36,
    0x74, 0x35, 0xED, 0xBE, 0x49, 0x14, 0x41, 0x44, 0x23, 0x2F, 0x2E, 0x9C, 0xC4, 0x35, 0x4B, 0x96,
    0xBD, 0xD2, 0x81, 0x71, 0x28, 0x49, 0x9F, 0xA2, 0xE9, 0x9A, 0x8C, 0x63, 0xBF, 0x83, 0x6C, 0x8A,
    0x99, 0x53, 0xD0, 0xDD, 0x8A, 0x61, 0xE0, 0xC4, 0x4C, 0x9B, 0x54, 0xEE, 0x7F, 0xCD, 0x33, 0x97,
    0x94, 0x0D, 0x99, 0x9F, 0xE8, 0xFF, 0x97, 0xA1, 0x38, 0x6B, 0x57, 0xAA, 0xB1, 0xF8, 0x4B, 0xEF,
    0xBB, 0x29, 0xAB, 0x25, 0xB0, 0x52, 0x59, 0x84, 0xE4, 0x08, 0x7E, 0x86, 0xEA, 0xD5, 0x39, 0xA4,
    0xAA, 0x96, 0x18, 0xB0, 0x51, 0xB0, 0x4C, 0xB9, 0x05, 0x41, 0x6D, 0x04, 0xDB, 0x05, 0x9C, 0x34,
    0xDC, 0x9A, 0x3F, 0x10, 0x46, 0xB6, 0xD7, 0x76, 0xA4, 0x28, 0xBB, 0xFF, 0xC0, 0xD2, 0xCC, 0xC2,
    0xC5, 0xB0, 0xD5, 0x1E, 0x9B, 0x37, 0xC3, 0x13, 0xC5, 0x1C, 0x2F, 0xA3, 0xAA, 0x6C, 0xD8, 0x99,

    0xB3, 0x20, 0xD9, 0xBA, 0xFA, 0x32, 0x54, 0xE9, 0x3C, 0x50, 0x92, 0x1A, 0x99, 0xC4, 0x25, 0xC1,
    0x91, 0x43, 0x71, 0x5D, 0x72, 0x5D, 0x09, 0x0C, 0x39, 0x04, 0x8D, 0x6B, 0x73, 0x20, 0x3F, 0x11,
    0xDC, 0xA5, 0xFA, 0x4B, 0x4C, 0xCB, 0xBD, 0x43, 0x2A, 0xFF, 0xE9, 0x32, 0xEC, 0x5C, 0x8E, 0xBB,
    0xE7, 0xFB, 0xA7, 0x8F, 0x72, 0x7B, 0x37, 0x6F, 0x20, 0x58, 0x93, 0xDE, 0xE0, 0xAA, 0x55, 0x07,
    0xC3, 0x41, 0x3F, 0x8C, 0xC6, 0x3F, 0x58, 0x3C, 0x0D, 0x0B, 0xBE, 0xA1, 0xDA, 0x30, 0xAB, 0x76,
    0x58, 0xB6, 0x06, 0xE8, 0xB8, 0x32, 0x2D, 0xA8, 0x6D, 0xA2, 0x30, 0xB9, 0xE3, 0x5F, 0x56, 0x71,
    0xD0, 0x56, 0x40, 0x7C, 0x77, 0xC4, 0x82, 0xD8, 0x0F, 0xEF, 0x67, 0x21, 0x7A, 0xBD, 0x4C, 0x31,
    0x88, 0xE7, 0x24, 0x9C, 0xE6, 0x7D, 0x5A, 0x17, 0x60, 0x69, 0xF7, 0x6D, 0x94, 0x24, 0x97, 0xEB,
    0x2B, 0xAD, 0x78, 0xAF, 0xC9, 0xA6, 0xC7, 0xE9, 0x1B, 0xE9, 0x92, 0xCA, 0x31, 0x00, 0x75, 0x50,
    0x87, 0x6B, 0x26, 0x0F, 0xBB, 0x63, 0xF2, 0x2E, 0x11, 0x69, 0x3D, 0x80, 0x85, 0xA2, 0xB1, 0x00,

    0x24, 0x39, 0x90, 0xA8, 0x7C, 0xB8, 0xEA, 0x7D, 0xD6, 0x0B, 0x23, 0x97, 0x4F, 0x49, 0xAE, 0xC2,
    0x55, 0x35, 0xC0, 0xBD, 0xE0, 0x11, 0x02, 0x48, 0xD1, 0x1B, 0xC1, 0x04, 0xCD, 0x34, 0x53, 0x50,
    0xCC, 0x07, 0x32, 0xC6, 0x2E, 0xD9, 0xA7, 0x70, 0x8F, 0x3F, 0x5F, 0xA5, 0x26, 0x75, 0x8E, 0xBE,
    0x5C, 0xC6, 0x61, 0x5C, 0x46, 0xCA, 0x50, 0xA9, 0x94, 0x31, 0xC1, 0xE2, 0x24, 0x67, 0xAD, 0x10,
    0x15, 0xD7, 0x01, 0x54, 0x4C, 0xC0, 0xA3, 0x6A, 0x56, 0xBA, 0xAB, 0x99, 0xA9, 0xB6, 0xA6, 0x16,
    0x5A, 0x42, 0x05, 0x8A, 0xDE, 0x62, 0x65, 0x64, 0xD1, 0x10, 0x81, 0xC6, 0xFD, 0x38, 0x63, 0xA1,
    0x4D, 0x91, 0x3D, 0x62, 0x37, 0xE9, 0x9C, 0x38, 0x91, 0x39, 0x2F, 0x79, 0xD8, 0x9A, 0x45, 0x9B,
    0xB0, 0x32, 0xD2, 0x6C, 0xB1, 0x46, 0xDD, 0xEC, 0xEC, 0x80, 0xF0, 0x36, 0x60,
};

uint8_t cert4[] = {
    0x30, 0x82, 0x05, 0x79, 0x30, 0x82, 0x03, 0x61, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0x31,
    0x9E, 0x12, 0xFD, 0x1C, 0x3A, 0x6D, 0x06, 0x51, 0x77, 0x4F, 0xA1, 0xA4, 0x07, 0x90, 0x5A, 0x61,
    0x5B, 0xDC, 0x50, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B,
    0x05, 0x00, 0x30, 0x47, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48,
    0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D,
    0x65, 0x6E, 0x74, 0x20, 0x53, 0x32, 0x20, 0x43, 0x41, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
    0x04, 0x0A, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x0B,
    0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x30, 0x1E, 0x17, 0x0D, 0x32,
    0x35, 0x30, 0x32, 0x32, 0x31, 0x30, 0x33, 0x33, 0x35, 0x35, 0x32, 0x5A, 0x17, 0x0D, 0x33, 0x35,
    0x30, 0x32, 0x31, 0x39, 0x30, 0x33, 0x33, 0x35, 0x35, 0x32, 0x5A, 0x30, 0x47, 0x31, 0x23, 0x30,

    0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43,
    0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x32, 0x20,
    0x43, 0x41, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0A, 0x48, 0x75, 0x61,
    0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06,
    0x13, 0x02, 0x43, 0x4E, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86,
    0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0F, 0x00, 0x30, 0x82, 0x02, 0x0A,
    0x02, 0x82, 0x02, 0x01, 0x00, 0xC4, 0x44, 0xD0, 0xFE, 0x01, 0x03, 0x1B, 0xEF, 0x92, 0xAA, 0xE6,
    0x9F, 0x85, 0x19, 0x8A, 0xFD, 0x2B, 0x15, 0x92, 0x42, 0x65, 0x67, 0xC8, 0x9D, 0xB6, 0x9C, 0x5D,
    0xDA, 0xEB, 0xA8, 0x9A, 0x9E, 0x5E, 0xA0, 0xF0, 0xA9, 0x24, 0xDF, 0x41, 0xA9, 0xDC, 0xA7, 0x1C,
    0x1E, 0x95, 0xF7, 0xAC, 0x7D, 0x01, 0xFE, 0xEA, 0xD2, 0x3C, 0x08, 0x99, 0xBA, 0x1D, 0xB8, 0xA9,

    0x69, 0x29, 0x0A, 0x8A, 0xE3, 0x43, 0xB5, 0x7E, 0x93, 0x67, 0xA3, 0xC2, 0x85, 0x98, 0x91, 0x87,
    0x05, 0x94, 0x93, 0x33, 0x11, 0x19, 0x42, 0x29, 0xA2, 0x01, 0x57, 0xD0, 0x66, 0x26, 0xE5, 0xBE,
    0x3B, 0x33, 0x1D, 0x26, 0x7F, 0x01, 0xE6, 0x16, 0x16, 0xF1, 0xFF, 0xDB, 0x5D, 0x4B, 0x43, 0x04,
    0x51, 0xF3, 0x88, 0x50, 0xCC, 0x7D, 0x5B, 0xBA, 0x2E, 0xFD, 0xFC, 0x81, 0xD8, 0x32, 0xDD, 0xD3,
    0x3E, 0x43, 0x77, 0xC9, 0xA2, 0xFD, 0x5F, 0x0D, 0x12, 0x06, 0x0C, 0x52, 0xDB, 0xEF, 0x02, 0x69,
    0xEF, 0x35, 0x6D, 0x8E, 0xFF, 0x71, 0xAA, 0x06, 0x20, 0x55, 0xD1, 0x7C, 0xDC, 0x4E, 0x8F, 0xE1,
    0xC0, 0x24, 0x8E, 0x01, 0xC8, 0x4C, 0x3A, 0xB3, 0xFE, 0x25, 0x83, 0x85, 0xA8, 0x9B, 0x40, 0x73,
    0xA4, 0xE2, 0x6D, 0xC4, 0xF1, 0xAC, 0x4E, 0x8D, 0x31, 0x45, 0xFF, 0xC1, 0x45, 0x59, 0xD8, 0x98,
    0xD7, 0x36, 0xA6, 0xB2, 0x40, 0x11, 0xFA, 0x94, 0x4B, 0xF5, 0x12, 0xA5, 0xC4, 0x3B, 0xFB, 0xED,
    0x97, 0xDA, 0x25, 0x32, 0x20, 0x7B, 0x7F, 0x97, 0xFE, 0xB4, 0xCB, 0x49, 0x36, 0xF2, 0x40, 0x78,

    0x7A, 0x50, 0x29, 0xED, 0x3E, 0x04, 0xF6, 0x69, 0xBE, 0x45, 0xAF, 0x8B, 0x9C, 0x89, 0x89, 0x21,
    0xB7, 0xEA, 0x83, 0xD1, 0x29, 0x13, 0x2A, 0xA5, 0x53, 0x7F, 0x12, 0x4D, 0xB9, 0x01, 0x2A, 0x5B,
    0xC1, 0x12, 0x04, 0xF8, 0xA0, 0xF0, 0x06, 0x13, 0x77, 0x5D, 0x48, 0x08, 0xCD, 0xFB, 0x4A, 0x22,
    0x71, 0xBB, 0xA9, 0x6F, 0x0F, 0x72, 0x52, 0x9E, 0xB2, 0x92, 0xF4, 0xED, 0xAF, 0x7A, 0xDD, 0x2A,
    0xEE, 0xB3, 0x23, 0x30, 0x9F, 0xB2, 0xCA, 0x3C, 0x3E, 0x20, 0xA8, 0xCB, 0xD5, 0xFE, 0x56, 0x05,
    0x43, 0xCB, 0xD0, 0x71, 0xB7, 0x32, 0x20, 0xD7, 0x0F, 0x9E, 0x73, 0x37, 0x57, 0x18, 0x78, 0xF0,
    0x33, 0x73, 0x36, 0x49, 0x39, 0xE5, 0xFE, 0x47, 0xA6, 0xC5, 0x34, 0xFC, 0xA7, 0x71, 0x3F, 0xDE,
    0x35, 0xA8, 0x65, 0x06, 0xC6, 0xE1, 0x2C, 0x2A, 0x24, 0xB5, 0xB0, 0x9E, 0x26, 0x8A, 0xDF, 0x4A,
    0x57, 0x41, 0x95, 0x2F, 0xE5, 0xCC, 0xB7, 0x8B, 0xCC, 0xBC, 0x99, 0xF4, 0xB6, 0xD0, 0xD4, 0x18,
    0x27, 0x3C, 0xC7, 0x0A, 0x63, 0x0A, 0x17, 0x98, 0xF9, 0xC9, 0xD3, 0x89, 0xE6, 0x4A, 0xAE, 0x08,

    0x65, 0xD0, 0xEE, 0x09, 0xE1, 0xC4, 0xAE, 0x9C, 0x1F, 0xA8, 0xED, 0x34, 0x64, 0x2B, 0xA2, 0xAA,
    0x30, 0xDF, 0xF6, 0xD1, 0x21, 0xA6, 0x85, 0xFB, 0x3E, 0x81, 0x2D, 0x60, 0xE7, 0x74, 0x25, 0x47,
    0x5A, 0xF6, 0x02, 0xC7, 0x5C, 0x3F, 0x64, 0xB0, 0x8A, 0x85, 0x8C, 0x91, 0x6C, 0x7A, 0x3E, 0x97,
    0x7A, 0x02, 0x44, 0xDF, 0xE0, 0x48, 0x65, 0xB5, 0x24, 0x57, 0x12, 0x83, 0xDB, 0x8B, 0x16, 0x93,
    0xE3, 0x14, 0x86, 0xA5, 0xCB, 0xE8, 0xB7, 0xFF, 0x9E, 0x15, 0x47, 0xD3, 0xB8, 0x8E, 0x63, 0x74,
    0xB4, 0x27, 0x13, 0x66, 0x10, 0x57, 0x2F, 0xB9, 0x9E, 0x1D, 0x2E, 0x1B, 0x04, 0x55, 0x76, 0xF1,
    0xFD, 0xA5, 0x25, 0x77, 0xAE, 0xD2, 0x70, 0xB5, 0x0B, 0xBF, 0x2B, 0xEE, 0x60, 0x2B, 0xBF, 0xD2,
    0x4D, 0x68, 0x46, 0xFF, 0x75, 0xE0, 0xA9, 0x7D, 0xE0, 0x8B, 0x2F, 0xFB, 0xC2, 0x06, 0x97, 0x60,
    0x64, 0xF0, 0xE4, 0x5A, 0xC3, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x5D, 0x30, 0x5B, 0x30, 0x0C,
    0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30, 0x0B, 0x06, 0x03,

    0x55, 0x1D, 0x0F, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E,
    0x04, 0x16, 0x04, 0x14, 0x88, 0xE4, 0xAA, 0x16, 0xA4, 0x95, 0x5A, 0xCB, 0xC7, 0xB8, 0x77, 0xE7,
    0x0A, 0x10, 0xFF, 0xEA, 0x18, 0x80, 0xE5, 0xB8, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04,
    0x18, 0x30, 0x16, 0x80, 0x14, 0x88, 0xE4, 0xAA, 0x16, 0xA4, 0x95, 0x5A, 0xCB, 0xC7, 0xB8, 0x77,
    0xE7, 0x0A, 0x10, 0xFF, 0xEA, 0x18, 0x80, 0xE5, 0xB8, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48,
    0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x86, 0x2F, 0xFF,
    0x37, 0x41, 0x52, 0xDC, 0x3D, 0xD3, 0xB1, 0xC7, 0x24, 0x24, 0xA1, 0xE7, 0x42, 0x35, 0xCD, 0x03,
    0x17, 0xCE, 0x3A, 0x32, 0x4C, 0x7D, 0x02, 0x85, 0x44, 0xCA, 0x00, 0x3F, 0x9A, 0xA4, 0xB0, 0x08,
    0x0B, 0x16, 0xC9, 0xAA, 0x75, 0x86, 0x49, 0x2D, 0x64, 0xB2, 0x92, 0x20, 0x22, 0xFA, 0x73, 0x0E,
    0xFC, 0xA8, 0xC8, 0x75, 0xB6, 0xCA, 0xCF, 0xB7, 0x2E, 0x35, 0x4D, 0x11, 0x0E, 0x95, 0x92, 0x5C,

    0xDB, 0x38, 0x28, 0x7E, 0x58, 0x3A, 0x5E, 0x3E, 0x38, 0xCB, 0xF7, 0x95, 0x4B, 0x50, 0x8D, 0x3B,
    0x73, 0x98, 0x60, 0x5A, 0x30, 0x79, 0x90, 0x09, 0x25, 0x2C, 0x3E, 0x00, 0x7C, 0x14, 0x5F, 0x0B,
    0x07, 0xC9, 0xC4, 0x80, 0xFF, 0xB5, 0x47, 0x0B, 0x63, 0x8C, 0x80, 0xF6, 0x13, 0x38, 0x15, 0x94,
    0x40, 0xAA, 0xA3, 0x83, 0x2A, 0xBF, 0x3D, 0xE9, 0x21, 0xDC, 0x17, 0x3F, 0x97, 0xFD, 0x23, 0x5A,
    0x2C, 0xC1, 0x6D, 0x0A, 0xE7, 0x77, 0x4B, 0xA9, 0xFF, 0x48, 0x3B, 0xCA, 0x99, 0x35, 0x1A, 0x76,
    0xF3, 0x04, 0x9A, 0x0F, 0x28, 0x60, 0x4A, 0x12, 0xFD, 0x64, 0xCA, 0xF0, 0x3F, 0xB7, 0xCC, 0x74,
    0xE1, 0xC4, 0xCF, 0x3B, 0xB8, 0xDA, 0x8A, 0xF4, 0x3D, 0x66, 0x34, 0xA6, 0x4E, 0x69, 0x39, 0x2A,
    0x86, 0xCC, 0xBF, 0x55, 0xBB, 0xE3, 0x9E, 0x42, 0xBC, 0x7D, 0xCF, 0xD1, 0xCD, 0x18, 0x6F, 0x4C,
    0x73, 0x00, 0xCB, 0xE6, 0xCD, 0x05, 0x9C, 0xFD, 0x0D, 0x38, 0xC5, 0x62, 0x54, 0x2E, 0x78, 0x04,
    0xF4, 0xF9, 0xF6, 0x71, 0x6C, 0x8A, 0xB2, 0x21, 0xEB, 0xEF, 0x9C, 0xAE, 0x33, 0x1E, 0x85, 0x97,

    0x67, 0x61, 0xD5, 0xF7, 0xFC, 0x4E, 0x36, 0xD4, 0xEA, 0x6A, 0x0C, 0x4D, 0x38, 0x91, 0x49, 0xB6,
    0x6B, 0x8C, 0x8A, 0xE1, 0x91, 0x01, 0x98, 0x3F, 0x7B, 0x85, 0x92, 0x3A, 0xEB, 0x61, 0xAF, 0xC8,
    0x60, 0x24, 0x66, 0x7F, 0xC9, 0x97, 0x4C, 0xAA, 0x6F, 0x1C, 0x46, 0x41, 0x1A, 0x09, 0x44, 0x66,
    0xED, 0xFA, 0x79, 0x0B, 0xC9, 0x22, 0x7D, 0x7B, 0xAF, 0xFC, 0x49, 0x8A, 0xC4, 0xB8, 0x78, 0x7C,
    0x9E, 0xD0, 0x39, 0x11, 0x5E, 0x29, 0x64, 0x75, 0x8A, 0xCC, 0x3D, 0x70, 0x29, 0x62, 0x32, 0x16,
    0xD3, 0x31, 0xF7, 0x6B, 0x70, 0x98, 0x06, 0x7F, 0x2D, 0xA3, 0xA1, 0xD2, 0x2F, 0x12, 0xFE, 0x06,
    0xF5, 0x28, 0x4F, 0x22, 0x0C, 0xCF, 0x5E, 0xDA, 0x42, 0x57, 0xFF, 0x51, 0xD9, 0xC9, 0x15, 0x4B,
    0xBA, 0x33, 0xF4, 0x8D, 0x9D, 0x17, 0x2D, 0x5A, 0x83, 0xAB, 0xCF, 0xA7, 0x4D, 0x2B, 0xE3, 0x45,
    0xCF, 0x47, 0x7B, 0x41, 0xDD, 0xF5, 0xEF, 0x2C, 0xB1, 0x6C, 0xD1, 0xB3, 0xB7, 0x1A, 0x6B, 0x2F,
    0xFB, 0x7C, 0x09, 0xEF, 0x1C, 0x35, 0xD9, 0xDF, 0x92, 0x33, 0xE1, 0x06, 0x8B, 0x79, 0x06, 0x5B,

    0x34, 0x9B, 0x2B, 0x1E, 0xA1, 0x04, 0xD4, 0x55, 0x8C, 0xB9, 0xFA, 0x4A, 0x3F, 0xCB, 0x62, 0x01,
    0x4B, 0x35, 0xDE, 0xB8, 0xDA, 0x4C, 0x4F, 0x77, 0xE4, 0x37, 0x40, 0x6F, 0x0F, 0xB2, 0x6B, 0x80,
    0xF5, 0x0E, 0x41, 0x89, 0x87, 0xD7, 0x78, 0xF0, 0x39, 0x81, 0xC3, 0xD9, 0x3A, 0xB8, 0x80, 0xA6,
    0xEA, 0xC2, 0x52, 0x7A, 0xEE, 0xEB, 0x85, 0xBD, 0x1C, 0xF3, 0x06, 0x68, 0x70, 0x2A, 0x8C, 0x40,
    0x7B, 0x6D, 0xFF, 0x13, 0x3E, 0x3C, 0xAB, 0xCD, 0xB2, 0x03, 0xBF, 0xF4, 0x1B, 0x43, 0x7F, 0x03,
    0x63, 0x72, 0xE5, 0xB9, 0xDC, 0xB6, 0x15, 0xD1, 0xF2, 0xC3, 0xBB, 0xF4, 0x37, 0xD4, 0x63, 0x67,
    0x78, 0x54, 0xF6, 0x20, 0x64, 0x85, 0xBD, 0x27, 0x2A, 0xFA, 0x12, 0x7D, 0xCA, 0xF6, 0xAC, 0x26,
    0xD6, 0x2E, 0xAD, 0x14, 0x6B, 0xFC, 0x86, 0x93, 0xB1, 0x7C, 0x1E, 0x15, 0x19,
};

uint8_t cert4good[] = {
    0x30, 0x82, 0x02, 0x1A, 0x30, 0x82, 0x01, 0xA1, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x4A,
    0x18, 0x69, 0x9F, 0x9D, 0x7D, 0x8C, 0xD0, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
    0x04, 0x03, 0x03, 0x30, 0x53, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
    0x43, 0x4E, 0x31, 0x0F, 0x30, 0x0D, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x06, 0x48, 0x75, 0x61,
    0x77, 0x65, 0x69, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x0A, 0x48, 0x75,
    0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x1E, 0x30, 0x1C, 0x06, 0x03, 0x55, 0x04,
    0x03, 0x0C, 0x15, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x20, 0x52, 0x6F,
    0x6F, 0x74, 0x20, 0x43, 0x41, 0x20, 0x47, 0x32, 0x30, 0x1E, 0x17, 0x0D, 0x32, 0x30, 0x30, 0x33,
    0x31, 0x36, 0x30, 0x33, 0x30, 0x34, 0x33, 0x39, 0x5A, 0x17, 0x0D, 0x34, 0x39, 0x30, 0x33, 0x31,
    0x36, 0x30, 0x33, 0x30, 0x34, 0x33, 0x39, 0x5A, 0x30, 0x53, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03,
    0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x0F, 0x30, 0x0D, 0x06, 0x03, 0x55, 0x04, 0x0A,
    0x0C, 0x06, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04,
    0x0B, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x1E, 0x30,
    0x1C, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x15, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43,
    0x42, 0x47, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41, 0x20, 0x47, 0x32, 0x30, 0x76, 0x30,
    0x10, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x05, 0x2B, 0x81, 0x04, 0x00,
    0x22, 0x03, 0x62, 0x00, 0x04, 0x5A, 0x27, 0x64, 0x1A, 0x70, 0xD2, 0x3B, 0x0D, 0xFF, 0x1C, 0x4D,
    0xB2, 0xD8, 0x61, 0xE5, 0xF9, 0xFA, 0x56, 0x04, 0x86, 0xB9, 0x4B, 0xE2, 0x25, 0x9C, 0xDA, 0xEC,
    0x19, 0x4B, 0xF0, 0x0B, 0x52, 0x36, 0x41, 0x6B, 0xED, 0xA8, 0x21, 0xD6, 0x9B, 0x01, 0x65, 0x14,
    0xAF, 0x79, 0xCC, 0xA5, 0xE2, 0x33, 0xCB, 0x3D, 0xC9, 0x5D, 0xD5, 0x55, 0x78, 0x7B, 0x8A, 0xF3,
    0x7C, 0x64, 0x93, 0xB7, 0x48, 0x2E, 0x4D, 0xD5, 0x30, 0xAB, 0xBC, 0x1D, 0xA5, 0xA4, 0x73, 0x01,
    0xC1, 0xCC, 0xF8, 0x0C, 0x0D, 0x24, 0x80, 0x70, 0x8C, 0x9B, 0xFC, 0x03, 0x79, 0xCE, 0xA4, 0x38,
    0x7C, 0x75, 0xC6, 0xF0, 0x91, 0xA3, 0x42, 0x30, 0x40, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F,
    0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, 0x13,
    0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D,
    0x0E, 0x04, 0x16, 0x04, 0x14, 0xA3, 0x8E, 0x5A, 0xF5, 0x5A, 0xBC, 0x71, 0x8C, 0x2A, 0x6A, 0x25,
    0x72, 0x7E, 0x48, 0x92, 0xE2, 0x92, 0xDC, 0x20, 0x00, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48,
    0xCE, 0x3D, 0x04, 0x03, 0x03, 0x03, 0x67, 0x00, 0x30, 0x64, 0x02, 0x30, 0x33, 0x2A, 0x5E, 0x07,
    0xB3, 0xF4, 0x21, 0xB6, 0x3B, 0x73, 0xA8, 0x29, 0x59, 0xC0, 0xA5, 0x85, 0x1C, 0xE7, 0x38, 0x91,
    0x63, 0xF2, 0xE6, 0xAF, 0xAC, 0xDB, 0xB6, 0x3C, 0x8A, 0x33, 0xF4, 0xA2, 0x2A, 0xAF, 0x78, 0xE7,
    0x06, 0x50, 0x47, 0x26, 0xCD, 0x26, 0xC8, 0x8E, 0xE7, 0xB5, 0x8A, 0x44, 0x02, 0x30, 0x5B, 0x9B,
    0xC7, 0x83, 0x31, 0x96, 0x39, 0xCE, 0xAE, 0x62, 0x31, 0x95, 0x02, 0xE8, 0x7E, 0xD4, 0xCD, 0x84,
    0xA2, 0xC7, 0x85, 0x32, 0xD5, 0x89, 0x6C, 0x2D, 0x55, 0x7B, 0xDF, 0xC3, 0xED, 0x28, 0xFF, 0x61,
    0x15, 0x38, 0xE0, 0x0C, 0x77, 0x2D, 0x5C, 0x99, 0x42, 0xE4, 0xBE, 0xFE, 0x64, 0x36,
};

uint8_t cert3good[] = {
    0x30, 0x82, 0x02, 0xF5, 0x30, 0x82, 0x02, 0x7B, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x49,
    0xAC, 0x1C, 0xD5, 0xE2, 0x4C, 0xC1, 0xD2, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
    0x04, 0x03, 0x03, 0x30, 0x53, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
    0x43, 0x4E, 0x31, 0x0F, 0x30, 0x0D, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x06, 0x48, 0x75, 0x61,
    0x77, 0x65, 0x69, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x0A, 0x48, 0x75,
    0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x1E, 0x30, 0x1C, 0x06, 0x03, 0x55, 0x04,
    0x03, 0x0C, 0x15, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x20, 0x52, 0x6F,
    0x6F, 0x74, 0x20, 0x43, 0x41, 0x20, 0x47, 0x32, 0x30, 0x1E, 0x17, 0x0D, 0x32, 0x30, 0x30, 0x33,
    0x31, 0x36, 0x31, 0x32, 0x30, 0x31, 0x30, 0x30, 0x5A, 0x17, 0x0D, 0x34, 0x30, 0x30, 0x33, 0x31,
    0x36, 0x31, 0x32, 0x30, 0x31, 0x30, 0x30, 0x5A, 0x30, 0x58, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03,
    0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x0F, 0x30, 0x0D, 0x06, 0x03, 0x55, 0x04, 0x0A,
    0x0C, 0x06, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04,
    0x0B, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x23, 0x30,
    0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43,
    0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x32, 0x20,
    0x43, 0x41, 0x30, 0x76, 0x30, 0x10, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06,
    0x05, 0x2B, 0x81, 0x04, 0x00, 0x22, 0x03, 0x62, 0x00, 0x04, 0xAC, 0x08, 0xAD, 0xDC, 0x4E, 0xE1,
    0x9F, 0x99, 0x4F, 0x08, 0x89, 0x93, 0x8C, 0x16, 0xDE, 0x6C, 0x2E, 0xE0, 0x30, 0x1D, 0xEF, 0xD7,
    0x67, 0x91, 0x46, 0xF4, 0x15, 0xE8, 0xAD, 0xFB, 0x03, 0x5E, 0xEF, 0x7E, 0x67, 0x33, 0xC7, 0xA4,
    0x19, 0x2B, 0x25, 0x77, 0x35, 0x51, 0x13, 0x7F, 0x59, 0xFA, 0x59, 0x64, 0x43, 0x32, 0xC2, 0x45,
    0xEE, 0x58, 0xB4, 0x69, 0x83, 0x34, 0xA6, 0x34, 0x95, 0x56, 0x77, 0x27, 0x06, 0x91, 0x23, 0x81,
    0x54, 0xC1, 0x00, 0x81, 0xED, 0xB6, 0x15, 0xB7, 0x2F, 0x46, 0x09, 0xAB, 0xC7, 0xAE, 0x29, 0x01,
    0x78, 0x8F, 0xD4, 0x4E, 0xE2, 0x2E, 0xB1, 0xC6, 0x81, 0x67, 0xA3, 0x82, 0x01, 0x15, 0x30, 0x82,
    0x01, 0x11, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xA3,
    0x8E, 0x5A, 0xF5, 0x5A, 0xBC, 0x71, 0x8C, 0x2A, 0x6A, 0x25, 0x72, 0x7E, 0x48, 0x92, 0xE2, 0x92,
    0xDC, 0x20, 0x00, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xFF, 0xE6,
    0xD9, 0x39, 0xC6, 0x7D, 0xE7, 0xBF, 0x02, 0xA6, 0xDB, 0xBA, 0x77, 0x21, 0x95, 0xDF, 0xE4, 0xCF,
    0x55, 0xE4, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03,
    0x01, 0x01, 0xFF, 0x30, 0x46, 0x06, 0x03, 0x55, 0x1D, 0x20, 0x04, 0x3F, 0x30, 0x3D, 0x30, 0x3B,
    0x06, 0x04, 0x55, 0x1D, 0x20, 0x00, 0x30, 0x33, 0x30, 0x31, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05,
    0x05, 0x07, 0x02, 0x01, 0x16, 0x25, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x63, 0x70, 0x6B,
    0x69, 0x2D, 0x63, 0x61, 0x77, 0x65, 0x62, 0x2E, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x2E, 0x63,
    0x6F, 0x6D, 0x2F, 0x63, 0x70, 0x6B, 0x69, 0x2F, 0x63, 0x70, 0x73, 0x30, 0x0E, 0x06, 0x03, 0x55,
    0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x66, 0x06, 0x03, 0x55,
    0x1D, 0x1F, 0x04, 0x5F, 0x30, 0x5D, 0x30, 0x5B, 0xA0, 0x59, 0xA0, 0x57, 0x86, 0x55, 0x68, 0x74,
    0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x63, 0x70, 0x6B, 0x69, 0x2D, 0x63, 0x61, 0x77, 0x65, 0x62, 0x2E,
    0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x63, 0x70, 0x6B, 0x69, 0x2F,
    0x73, 0x65, 0x72, 0x76, 0x6C, 0x65, 0x74, 0x2F, 0x63, 0x72, 0x6C, 0x46, 0x69, 0x6C, 0x65, 0x44,
    0x6F, 0x77, 0x6E, 0x2E, 0x63, 0x72, 0x6C, 0x3F, 0x63, 0x65, 0x72, 0x74, 0x79, 0x70, 0x65, 0x3D,
    0x31, 0x30, 0x26, 0x2F, 0x72, 0x6F, 0x6F, 0x74, 0x5F, 0x67, 0x32, 0x5F, 0x63, 0x72, 0x6C, 0x2E,
    0x63, 0x72, 0x6C, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x03, 0x03,
    0x68, 0x00, 0x30, 0x65, 0x02, 0x30, 0x71, 0x21, 0x99, 0x88, 0x31, 0x40, 0x3F, 0x52, 0xE0, 0x0D,
    0x44, 0xAA, 0x7E, 0xC1, 0x7F, 0x18, 0x73, 0x43, 0xD9, 0xD4, 0x0B, 0xA4, 0x50, 0xA3, 0x31, 0xDE,
    0xB5, 0xF4, 0x70, 0xE6, 0xDC, 0xFE, 0x6E, 0xC2, 0xE8, 0x2A, 0xE4, 0xC1, 0xD7, 0xBF, 0xE4, 0x93,
    0x38, 0x02, 0xD2, 0x3D, 0xA6, 0xA9, 0x02, 0x31, 0x00, 0xA6, 0xF1, 0x32, 0xE7, 0x12, 0xD4, 0x43,
    0xD9, 0x6C, 0x77, 0xF7, 0x11, 0x9C, 0x38, 0x55, 0x4C, 0x91, 0x6A, 0x1C, 0xD7, 0xE0, 0xEA, 0xE5,
    0xFE, 0x53, 0x28, 0xB3, 0x77, 0x67, 0x1A, 0x6F, 0x4C, 0x03, 0x75, 0xBB, 0x09, 0xAD, 0x23, 0x44,
    0xB3, 0xA3, 0x03, 0xA8, 0x40, 0x66, 0xCC, 0x82, 0x0E,
};

uint8_t cert2good[] = {
    0x30, 0x82, 0x03, 0x1D, 0x30, 0x82, 0x02, 0xA3, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x12, 0x20,
    0x24, 0x06, 0x11, 0x17, 0x18, 0x41, 0x6D, 0xF1, 0x9B, 0xC9, 0x42, 0xE8, 0x11, 0xAC, 0x31, 0x86,
    0x12, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x03, 0x30, 0x58, 0x31,
    0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x0F, 0x30, 0x0D,
    0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x06, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x31, 0x13, 0x30,
    0x11, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43,
    0x42, 0x47, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1A, 0x48, 0x75, 0x61,
    0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x20, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6D, 0x65, 0x6E,
    0x74, 0x20, 0x53, 0x32, 0x20, 0x43, 0x41, 0x30, 0x1E, 0x17, 0x0D, 0x32, 0x34, 0x30, 0x36, 0x31,
    0x31, 0x30, 0x39, 0x31, 0x38, 0x34, 0x31, 0x5A, 0x17, 0x0D, 0x33, 0x34, 0x30, 0x36, 0x31, 0x31,
    0x30, 0x39, 0x31, 0x38, 0x34, 0x31, 0x5A, 0x30, 0x6F, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55,
    0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x0F, 0x30, 0x0D, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C,
    0x06, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0B,
    0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42, 0x47, 0x31, 0x3A, 0x30, 0x38,
    0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x31, 0x48, 0x55, 0x41, 0x57, 0x45, 0x49, 0x5F, 0x48, 0x57,
    0x50, 0x4C, 0x52, 0x5F, 0x65, 0x65, 0x64, 0x35, 0x35, 0x32, 0x66, 0x36, 0x2D, 0x65, 0x33, 0x32,
    0x66, 0x2D, 0x34, 0x38, 0x63, 0x38, 0x2D, 0x38, 0x38, 0x37, 0x34, 0x2D, 0x34, 0x62, 0x32, 0x61,
    0x34, 0x31, 0x61, 0x61, 0x66, 0x37, 0x38, 0x34, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86,
    0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03,
    0x42, 0x00, 0x04, 0xDA, 0x99, 0xB7, 0xAE, 0x30, 0xD1, 0xBC, 0xA5, 0x8B, 0x6A, 0x1F, 0x34, 0x01,
    0x79, 0x0D, 0x56, 0x55, 0xE9, 0x9A, 0xA7, 0xC5, 0xFA, 0x87, 0x6D, 0xF5, 0x14, 0xE3, 0x10, 0x8E,
    0x03, 0xD2, 0xAE, 0xFC, 0xF1, 0x0D, 0xFB, 0x7A, 0xF9, 0xE5, 0xEE, 0x82, 0x1B, 0xCC, 0xF6, 0x01,
    0x5A, 0x2A, 0x6E, 0xB0, 0x4F, 0x2B, 0x1C, 0xD6, 0x3F, 0x43, 0xA7, 0xBE, 0x89, 0x92, 0xB8, 0x8B,
    0xAB, 0xDE, 0x32, 0xA3, 0x82, 0x01, 0x34, 0x30, 0x82, 0x01, 0x30, 0x30, 0x1F, 0x06, 0x03, 0x55,
    0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xFF, 0xE6, 0xD9, 0x39, 0xC6, 0x7D, 0xE7, 0xBF,
    0x02, 0xA6, 0xDB, 0xBA, 0x77, 0x21, 0x95, 0xDF, 0xE4, 0xCF, 0x55, 0xE4, 0x30, 0x1D, 0x06, 0x03,
    0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xD1, 0xA8, 0x64, 0x63, 0x27, 0xAB, 0x17, 0x79, 0x27,
    0x01, 0x57, 0x13, 0x68, 0x7A, 0x3C, 0xFE, 0xCC, 0xAF, 0x09, 0xAA, 0x30, 0x46, 0x06, 0x03, 0x55,
    0x1D, 0x20, 0x04, 0x3F, 0x30, 0x3D, 0x30, 0x3B, 0x06, 0x04, 0x55, 0x1D, 0x20, 0x00, 0x30, 0x33,
    0x30, 0x31, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01, 0x16, 0x25, 0x68, 0x74,
    0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x70, 0x6B, 0x69, 0x2E, 0x63, 0x6F, 0x6E, 0x73, 0x75, 0x6D, 0x65,
    0x72, 0x2E, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x63, 0x61, 0x2F,
    0x63, 0x70, 0x73, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x08, 0x30,
    0x06, 0x01, 0x01, 0xFF, 0x02, 0x01, 0x00, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01,
    0xFF, 0x04, 0x04, 0x03, 0x02, 0x02, 0xB4, 0x30, 0x49, 0x06, 0x03, 0x55, 0x1D, 0x1F, 0x04, 0x42,
    0x30, 0x40, 0x30, 0x3E, 0xA0, 0x3C, 0xA0, 0x3A, 0x86, 0x38, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F,
    0x2F, 0x70, 0x6B, 0x69, 0x2E, 0x63, 0x6F, 0x6E, 0x73, 0x75, 0x6D, 0x65, 0x72, 0x2E, 0x68, 0x75,
    0x61, 0x77, 0x65, 0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x63, 0x61, 0x2F, 0x63, 0x72, 0x6C, 0x2F,
    0x65, 0x71, 0x75, 0x5F, 0x73, 0x32, 0x2F, 0x63, 0x72, 0x6C, 0x32, 0x30, 0x32, 0x34, 0x2E, 0x63,
    0x72, 0x6C, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06, 0x08, 0x2B,
    0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03,
    0x02, 0x30, 0x18, 0x06, 0x0C, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x8F, 0x5B, 0x02, 0x82, 0x78, 0x01,
    0x01, 0x04, 0x08, 0x30, 0x06, 0x02, 0x01, 0x01, 0x0A, 0x01, 0x02, 0x30, 0x0A, 0x06, 0x08, 0x2A,
    0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x03, 0x03, 0x68, 0x00, 0x30, 0x65, 0x02, 0x31, 0x00, 0x84,
    0xA8, 0xD7, 0xAD, 0x5B, 0xF2, 0x93, 0x05, 0xE1, 0x0F, 0xC8, 0x45, 0xC3, 0x48, 0x50, 0x91, 0xFE,
    0xF3, 0xE5, 0x5C, 0x71, 0x49, 0x2E, 0x54, 0xBD, 0x1A, 0x2E, 0x9D, 0x8B, 0x5E, 0x4D, 0x5E, 0x19,
    0xF1, 0x8F, 0xB7, 0x8F, 0xDF, 0x27, 0x20, 0x09, 0x3B, 0x53, 0x28, 0x41, 0x5B, 0xC1, 0x45, 0x02,
    0x30, 0x47, 0x4F, 0x1C, 0x49, 0xBF, 0xE9, 0x30, 0x19, 0xBB, 0x0D, 0x24, 0x08, 0xD7, 0x0E, 0x83,
    0x4D, 0xB9, 0x6D, 0x27, 0xD8, 0x7F, 0xF9, 0x34, 0x82, 0xB9, 0x18, 0x47, 0x3E, 0x9A, 0x2B, 0x1E,
    0x1B, 0x70, 0x57, 0x2C, 0x8E, 0x70, 0x57, 0x08, 0x90, 0x60, 0xD8, 0x4F, 0x5F, 0x7E, 0xB8, 0xB1,
    0x53,
};

uint8_t cert1good[] = {
    0x30, 0x82, 0x03, 0x19, 0x30, 0x82, 0x02, 0xBF, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01,
    0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x6F, 0x31, 0x0B,
    0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x0F, 0x30, 0x0D, 0x06,
    0x03, 0x55, 0x04, 0x0A, 0x0C, 0x06, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x31, 0x13, 0x30, 0x11,
    0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x0A, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x20, 0x43, 0x42,
    0x47, 0x31, 0x3A, 0x30, 0x38, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x31, 0x48, 0x55, 0x41, 0x57,
    0x45, 0x49, 0x5F, 0x48, 0x57, 0x50, 0x4C, 0x52, 0x5F, 0x65, 0x65, 0x64, 0x35, 0x35, 0x32, 0x66,
    0x36, 0x2D, 0x65, 0x33, 0x32, 0x66, 0x2D, 0x34, 0x38, 0x63, 0x38, 0x2D, 0x38, 0x38, 0x37, 0x34,
    0x2D, 0x34, 0x62, 0x32, 0x61, 0x34, 0x31, 0x61, 0x61, 0x66, 0x37, 0x38, 0x34, 0x30, 0x1E, 0x17,
    0x0D, 0x32, 0x34, 0x30, 0x36, 0x31, 0x31, 0x30, 0x39, 0x31, 0x38, 0x34, 0x31, 0x5A, 0x17, 0x0D,
    0x33, 0x34, 0x30, 0x36, 0x31, 0x31, 0x30, 0x39, 0x31, 0x38, 0x34, 0x31, 0x5A, 0x30, 0x2C, 0x31,
    0x2A, 0x30, 0x28, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x21, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
    0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x4D, 0x61, 0x6E,
    0x61, 0x67, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4B, 0x65, 0x79, 0x30, 0x2A, 0x30, 0x05, 0x06,
    0x03, 0x2B, 0x65, 0x6E, 0x03, 0x21, 0x00, 0x42, 0x80, 0x20, 0x36, 0x27, 0x20, 0x3A, 0xD2, 0x28,
    0x1D, 0xF2, 0x97, 0x05, 0x9A, 0xBA, 0x75, 0x26, 0xB5, 0x0C, 0x8B, 0xD7, 0x07, 0x27, 0x62, 0xAC,
    0x1A, 0x47, 0x4D, 0x75, 0x78, 0xFD, 0x41, 0xA3, 0x82, 0x01, 0xBC, 0x30, 0x82, 0x01, 0xB8, 0x30,
    0x0B, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x04, 0x04, 0x03, 0x02, 0x03, 0xA8, 0x30, 0x82, 0x01, 0xA7,
    0x06, 0x0C, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x8F, 0x5B, 0x02, 0x82, 0x78, 0x01, 0x03, 0x04, 0x82,
    0x01, 0x95, 0x30, 0x82, 0x01, 0x91, 0x02, 0x01, 0x00, 0x30, 0x22, 0x02, 0x01, 0x00, 0x06, 0x0D,
    0x2B, 0x06, 0x01, 0x04, 0x01, 0x8F, 0x5B, 0x02, 0x82, 0x78, 0x02, 0x01, 0x04, 0x04, 0x0E, 0x63,
    0x68, 0x61, 0x6C, 0x6C, 0x65, 0x6E, 0x67, 0x65, 0x5F, 0x64, 0x61, 0x74, 0x61, 0x30, 0x81, 0xCF,
    0x02, 0x01, 0x02, 0x06, 0x0D, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x8F, 0x5B, 0x02, 0x82, 0x78, 0x02,
    0x01, 0x03, 0x30, 0x81, 0xBA, 0x06, 0x0E, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x8F, 0x5B, 0x02, 0x82,
    0x78, 0x02, 0x01, 0x03, 0x01, 0x04, 0x81, 0xA7, 0x7B, 0x22, 0x61, 0x70, 0x70, 0x49, 0x64, 0x22,
    0x3A, 0x22, 0x63, 0x6F, 0x6D, 0x2E, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x6D, 0x79,
    0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x5F, 0x42, 0x48, 0x7A, 0x53,
    0x39, 0x66, 0x50, 0x62, 0x63, 0x48, 0x38, 0x78, 0x6A, 0x4C, 0x36, 0x77, 0x2B, 0x47, 0x6E, 0x55,
    0x46, 0x6E, 0x33, 0x6A, 0x4E, 0x38, 0x44, 0x38, 0x4B, 0x61, 0x4F, 0x4B, 0x61, 0x66, 0x57, 0x48,
    0x65, 0x33, 0x62, 0x77, 0x37, 0x66, 0x55, 0x78, 0x57, 0x6E, 0x6B, 0x55, 0x63, 0x4F, 0x32, 0x4C,
    0x44, 0x52, 0x6C, 0x50, 0x35, 0x68, 0x59, 0x73, 0x50, 0x44, 0x36, 0x54, 0x58, 0x51, 0x5A, 0x45,
    0x4E, 0x65, 0x6C, 0x59, 0x6C, 0x51, 0x41, 0x6E, 0x71, 0x46, 0x68, 0x5A, 0x78, 0x31, 0x51, 0x63,
    0x72, 0x48, 0x51, 0x3D, 0x22, 0x2C, 0x22, 0x62, 0x75, 0x6E, 0x64, 0x6C, 0x65, 0x4E, 0x61, 0x6D,
    0x65, 0x22, 0x3A, 0x22, 0x63, 0x6F, 0x6D, 0x2E, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E,
    0x6D, 0x79, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x22, 0x7D, 0x30,
    0x55, 0x02, 0x01, 0x03, 0x06, 0x0E, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x8F, 0x5B, 0x02, 0x82, 0x78,
    0x02, 0x02, 0x02, 0x09, 0x04, 0x40, 0x42, 0x45, 0x31, 0x30, 0x43, 0x35, 0x46, 0x39, 0x41, 0x34,
    0x46, 0x41, 0x32, 0x46, 0x46, 0x43, 0x31, 0x38, 0x31, 0x30, 0x32, 0x42, 0x31, 0x45, 0x46, 0x43,
    0x37, 0x31, 0x35, 0x44, 0x41, 0x46, 0x33, 0x44, 0x38, 0x34, 0x39, 0x33, 0x46, 0x33, 0x39, 0x32,
    0x42, 0x44, 0x39, 0x46, 0x39, 0x35, 0x35, 0x38, 0x44, 0x33, 0x33, 0x36, 0x33, 0x41, 0x34, 0x32,
    0x36, 0x35, 0x44, 0x35, 0x30, 0x45, 0x30, 0x25, 0x02, 0x01, 0x03, 0x06, 0x0E, 0x2B, 0x06, 0x01,
    0x04, 0x01, 0x8F, 0x5B, 0x02, 0x82, 0x78, 0x02, 0x02, 0x02, 0x06, 0x04, 0x10, 0x28, 0xC4, 0xFB,
    0x49, 0x44, 0xAF, 0xEC, 0x11, 0xB9, 0x09, 0x02, 0x42, 0xAC, 0x12, 0x00, 0x02, 0x30, 0x18, 0x02,
    0x01, 0x02, 0x06, 0x0D, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x8F, 0x5B, 0x02, 0x82, 0x78, 0x02, 0x01,
    0x05, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
    0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x79, 0x3D, 0xA4, 0x01, 0x82, 0xBE,
    0xD6, 0x6F, 0xA0, 0x24, 0x82, 0x2B, 0x91, 0x30, 0x11, 0x7F, 0x57, 0x95, 0xF0, 0x20, 0xE8, 0x3F,
    0x03, 0xEC, 0xE1, 0x1F, 0xBD, 0x9F, 0x8C, 0x99, 0x2A, 0x21, 0x02, 0x21, 0x00, 0xA3, 0x23, 0x85,
    0x93, 0xA1, 0xD1, 0xBB, 0x90, 0xAC, 0x7E, 0x5B, 0x9D, 0xCD, 0x0A, 0xE0, 0xC5, 0x43, 0xA1, 0x9F,
    0x94, 0x44, 0x37, 0x25, 0x4F, 0xDF, 0xDC, 0x7E, 0xDC, 0xDE, 0x4A, 0x50, 0x78,
};

static struct HksBlob g_secInfo = { sizeof(SEC_INFO_DATA), (uint8_t *)SEC_INFO_DATA };
static struct HksBlob g_challenge = { sizeof(CHALLENGE_DATA), (uint8_t *)CHALLENGE_DATA };
static struct HksBlob g_version = { sizeof(VERSION_DATA), (uint8_t *)VERSION_DATA };

#define CERT_COUNT_2 2
#define CERT_COUNT_3 3
#define CERT_COUNT_5 5

class HksAttestKeyNonIdsTest : public testing::Test {
public:
    static void SetUpTestCase(void);

    static void TearDownTestCase(void);

    void SetUp();

    void TearDown();
};

void HksAttestKeyNonIdsTest::SetUpTestCase(void)
{
}

void HksAttestKeyNonIdsTest::TearDownTestCase(void)
{
}

void HksAttestKeyNonIdsTest::SetUp()
{
}

void HksAttestKeyNonIdsTest::TearDown()
{
}

static const struct HksBlob g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };

static const struct HksParam g_commonParams[] = {
    { .tag = HKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, .blob = g_secInfo },
    { .tag = HKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge },
    { .tag = HKS_TAG_ATTESTATION_ID_VERSION_INFO, .blob = g_version },
    { .tag = HKS_TAG_ATTESTATION_ID_ALIAS, .blob = g_keyAlias },
};

#ifndef TEMP_ISOLATION
static const uint32_t g_keyParamsetSize = 1024;

static void ValidateCertChain(struct HksParamSet *paramSet, struct HksParamSet *paramOutSet,
    HksCertChain *certChain)
{
    struct HksParam g_getParam = {
        .tag = HKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA,
        .blob = { .size = g_keyParamsetSize, .data = (uint8_t *)HksMalloc(g_keyParamsetSize) }
    };
    ASSERT_NE(g_getParam.blob.data, nullptr);
    struct HksParam *keySizeParam = nullptr;
    uint32_t rootUid = 0;
    HksInitParamSet(&paramOutSet);
    HksAddParams(paramOutSet, &g_getParam, 1);
    HksBuildParamSet(&paramOutSet);
    HKS_FREE(g_getParam.blob.data);
    int32_t ret = HksGetKeyParamSetForDe(&g_keyAlias, nullptr, paramOutSet);
    ASSERT_EQ(ret, HKS_SUCCESS);
    ret = HksGetParam(paramOutSet, HKS_TAG_KEY_SIZE, &keySizeParam);
    ASSERT_EQ(ret, HKS_SUCCESS);
    ASSERT_EQ(keySizeParam->uint32Param, HKS_RSA_KEY_SIZE_2048);
    struct HksParam *processParam = nullptr;
    ret = HksGetParam(paramOutSet, HKS_TAG_PROCESS_NAME, &processParam);
    ASSERT_EQ(ret, HKS_SUCCESS);
    ASSERT_EQ(sizeof(rootUid), processParam->blob.size);
    ASSERT_EQ(HksMemCmp(processParam->blob.data, &rootUid, processParam->blob.size), HKS_SUCCESS);

    HksFreeParamSet(&paramOutSet);

    ret = ValidateCertChainTest(certChain, g_commonParams, NON_IDS_PARAM);
    FreeCertChain(&certChain, certChain->certsCount);
    certChain = nullptr;

    HksFreeParamSet(&paramSet);

    ret = HksDeleteKeyForDe(&g_keyAlias, nullptr);
    ASSERT_EQ(ret, HKS_SUCCESS);
}
#endif

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest001
 * @tc.desc: attest with right params and permission.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest001, TestSize.Level0)
{
    HKS_LOG_I("enter HksAttestKeyNonIdsTest001");
    int32_t ret = SetIdsTokenForAttestKeyPermission();
    EXPECT_EQ(ret, HKS_SUCCESS);

    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    ASSERT_EQ(ret, HKS_SUCCESS);

    ret = SetIdsTokenWithoutPermission();
    EXPECT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest002
 * @tc.desc: attest without cert data and fail.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest002, TestSize.Level0)
{
    HKS_LOG_I("enter HksAttestKeyNonIdsTest002");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    struct HksParamSet *paramSet = NULL;
    HksCertChain *certChain = NULL;
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, false, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    ASSERT_EQ(ret, HKS_ERROR_INVALID_ARGUMENT);

    FreeCertChain(&certChain, certChain->certsCount);
    certChain = NULL;

    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAnonAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    ASSERT_EQ(ret, HKS_ERROR_INVALID_ARGUMENT);
    FreeCertChain(&certChain, certChain->certsCount);
    certChain = NULL;
    HksFreeParamSet(&paramSet);

    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest003
 * @tc.desc: attest without cert count and fail.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest003, TestSize.Level0)
{
    HKS_LOG_I("enter HksAttestKeyNonIdsTest003");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    struct HksParamSet *paramSet = NULL;
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    HksCertChain *certChain = NULL;
    const struct HksTestCertChain certParam = { true, false, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    ASSERT_EQ(ret, HKS_ERROR_INVALID_ARGUMENT);

    FreeCertChain(&certChain, certChain->certsCount);

    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAnonAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    ASSERT_EQ(ret, HKS_ERROR_INVALID_ARGUMENT);

    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&paramSet);

    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest004
 * @tc.desc: attest without cert chain and fail.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest004, TestSize.Level0)
{
    HKS_LOG_I("enter HksAttestKeyNonIdsTest004");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    struct HksParamSet *paramSet = NULL;
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    HksCertChain *certChain = NULL;
    const struct HksTestCertChain certParam = { false, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    ASSERT_EQ(ret, HKS_ERROR_NULL_POINTER);
    if (certChain != NULL) {
        FreeCertChain(&certChain, certChain->certsCount);
    }

    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAnonAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    ASSERT_EQ(ret, HKS_ERROR_NULL_POINTER);
    if (certChain != NULL) {
        FreeCertChain(&certChain, certChain->certsCount);
    }

    HksFreeParamSet(&paramSet);

    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest005
 * @tc.desc: attest with base64 and validate success.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest005, TestSize.Level0)
{
    HKS_LOG_I("enter HksAttestKeyNonIdsTest005");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    struct HksParam g_commonParams[] = {
        { .tag = HKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, .blob = g_secInfo },
        { .tag = HKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge },
        { .tag = HKS_TAG_ATTESTATION_ID_VERSION_INFO, .blob = g_version },
        { .tag = HKS_TAG_ATTESTATION_ID_ALIAS, .blob = g_keyAlias },
        { .tag = HKS_TAG_ATTESTATION_BASE64, .boolParam = true },
    };
    struct HksParamSet *paramSet = NULL;
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    HksCertChain *certChain = NULL;
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);

    ASSERT_EQ(ret, HKS_ERROR_NO_PERMISSION);
    ret = ValidateCertChainTest(certChain, g_commonParams, NON_IDS_BASE64_PARAM);

    FreeCertChain(&certChain, certChain->certsCount);
    certChain = NULL;
    HksFreeParamSet(&paramSet);

    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest007
 * @tc.desc: attest with device id and expect HKS_ERROR_NO_PERMISSION
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest007, TestSize.Level0)
{
    HKS_LOG_I("enter HksAttestKeyNonIdsTest007");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    static struct HksBlob dId = { sizeof(DEVICE_ID), (uint8_t *)DEVICE_ID };
    struct HksParam g_commonParams[] = {
        { .tag = HKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, .blob = g_secInfo },
        { .tag = HKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge },
        { .tag = HKS_TAG_ATTESTATION_ID_VERSION_INFO, .blob = g_version },
        { .tag = HKS_TAG_ATTESTATION_ID_ALIAS, .blob = g_keyAlias },
        { .tag = HKS_TAG_ATTESTATION_ID_DEVICE, .blob = dId },
        { .tag = HKS_TAG_ATTESTATION_BASE64, .boolParam = true },
    };
    struct HksParamSet *paramSet = NULL;
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    HksCertChain *certChain = NULL;
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);

    ASSERT_EQ(ret, HKS_ERROR_NO_PERMISSION);

    FreeCertChain(&certChain, certChain->certsCount);
    certChain = NULL;
    HksFreeParamSet(&paramSet);

    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest008
 * @tc.desc: attest with right params(use pksc1_v1_5 for padding) and validate success.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest008, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest008");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PKCS1_V1_5);
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("HksAttestKey fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_ERROR_NO_PERMISSION);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest009
 * @tc.desc: attest with right params and validate success.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest009, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest009");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAnonAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("HksAnonAttestKey fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest010
 * @tc.desc: attest with right params(use pksc1_v1_5 for padding) and validate success.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest010, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest010");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PKCS1_V1_5);
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAnonAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("HksAnonAttestKey fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest011
 * @tc.desc: attest with right params.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest011, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest011");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("OH_Huks_AnonAttestKeyItem fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest012
 * @tc.desc: attest ECC with right params.
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest012, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest012");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_ECC },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_ECC_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY },
        { .tag = HKS_TAG_DIGEST, .uint32Param = HKS_DIGEST_SHA384 },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    ret = GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    ret = ConstructDataToCertChain(&certChain, &certParam);
    ASSERT_EQ(ret, HKS_SUCCESS);
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    HKS_LOG_I("OH_Huks_AnonAttestKeyItem, ret is %" LOG_PUBLIC "d!", ret);
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest013
 * @tc.desc: attest with right params.
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest013, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest013");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_SM2 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_SM2_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT },
        { .tag = HKS_TAG_DIGEST, .uint32Param = HKS_DIGEST_SM3},
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    ret = GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    ret = ConstructDataToCertChain(&certChain, &certParam);
    ASSERT_EQ(ret, HKS_SUCCESS);
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    HKS_LOG_I("OH_Huks_AnonAttestKeyItem, ret is %" LOG_PUBLIC "d!", ret);
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest014
 * @tc.desc: attest with x25519.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest014, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest014");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_X25519 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_CURVE25519_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_AGREE },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("HksAttestKey fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_ERROR_NO_PERMISSION);

    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest015
 * @tc.desc: attest with x25519.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest015, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest015");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_X25519 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_CURVE25519_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_AGREE },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAnonAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("HksAnonAttestKey fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);

    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest016
 * @tc.desc: attest with x25519.
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest016, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest016");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_X25519 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_CURVE25519_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_AGREE },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    ret = GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    ret = ConstructDataToCertChain(&certChain, &certParam);
    ASSERT_EQ(ret, HKS_SUCCESS);
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    HKS_LOG_I("OH_Huks_AnonAttestKeyItem, ret is %" LOG_PUBLIC "d!", ret);
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest017
 * @tc.desc: attest with ed25519.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest017, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest017");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_ED25519 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_CURVE25519_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_VERIFY },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("HksAttestKey fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_ERROR_NO_PERMISSION);

    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest018
 * @tc.desc: attest with ed25519.
 * @tc.type: FUNC
 * @tc.require: issueI5NY0L
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest018, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest018");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_ED25519 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_CURVE25519_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_VERIFY },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    (void)ConstructDataToCertChain(&certChain, &certParam);
    ret = HksAnonAttestKeyForDe(&g_keyAlias, paramSet, certChain);
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("HksAnonAttestKey fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);

    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest019
 * @tc.desc: attest with ed25519.
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest019, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest019");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_ED25519 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_CURVE25519_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_VERIFY },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    ret = GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    const struct HksTestCertChain certParam = { true, true, true, g_size };
    ret = ConstructDataToCertChain(&certChain, &certParam);
    ASSERT_EQ(ret, HKS_SUCCESS);
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    HKS_LOG_I("OH_Huks_AnonAttestKeyItem, ret is %" LOG_PUBLIC "d!", ret);
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest020
 * @tc.desc: attest with pss(return of three certificates)
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest020, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest020");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
 
    (void)ConstructDataToCertChainWithCount(&certChain, &certParam, CERT_COUNT_3);
 
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("OH_Huks_AnonAttestKeyItem fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest021
 * @tc.desc: attest with ed25519(return of three certificates)
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest021, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest021");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_ED25519 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_CURVE25519_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_VERIFY },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
 
    (void)ConstructDataToCertChainWithCount(&certChain, &certParam, CERT_COUNT_3);
 
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("OH_Huks_AnonAttestKeyItem fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest022
 * @tc.desc: attest with x25519(return of three certificates)
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest022, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest022");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_X25519 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_CURVE25519_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_AGREE },
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
 
    (void)ConstructDataToCertChainWithCount(&certChain, &certParam, CERT_COUNT_3);
 
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("OH_Huks_AnonAttestKeyItem fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest023
 * @tc.desc: attest with pss(return of three certificates)
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest023, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest023");
    const struct HksParam tmpParams[] = {
        { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_SM2 },
        { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_SM2_KEY_SIZE_256 },
        { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT },
        { .tag = HKS_TAG_DIGEST, .uint32Param = HKS_DIGEST_SM3},
    };
    int32_t ret = TestGenerateKeyCommon(&g_keyAlias, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0]));
    ASSERT_EQ(ret, HKS_SUCCESS);
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
 
    (void)ConstructDataToCertChainWithCount(&certChain, &certParam, CERT_COUNT_3);
 
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("OH_Huks_AnonAttestKeyItem fail, ret is %" LOG_PUBLIC "d!", ret);
    }
    ASSERT_EQ(ret, HKS_SUCCESS);
    for (uint32_t i = 0; i < certChain->certsCount; i++) {
        printf("Get certChain[%d]:\n %s \n", i, certChain->certs[i].data);
    }
    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest024
 * @tc.desc: attest with false certificates num
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest024, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest024");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    struct HksParam g_commonParams[] = {
        { .tag = HKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, .blob = g_secInfo },
        { .tag = HKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge },
        { .tag = HKS_TAG_ATTESTATION_ID_VERSION_INFO, .blob = g_version },
        { .tag = HKS_TAG_ATTESTATION_ID_ALIAS, .blob = g_keyAlias },
        { .tag = HKS_TAG_ATTESTATION_BASE64, .boolParam = true },
    };
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
 
    (void)ConstructDataToCertChainWithCount(&certChain, &certParam, CERT_COUNT_2);
    ret = ValidateCertChainTest(certChain, g_commonParams, NON_IDS_PARAM);
    ASSERT_EQ(ret, HKS_ERROR_INVALID_ARGUMENT);
 
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("OH_Huks_AnonAttestKeyItem fail, ret is %" LOG_PUBLIC "d!", ret);
    }

    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

/**
 * @tc.name: HksAttestKeyNonIdsTest.HksAttestKeyNonIdsTest025
 * @tc.desc: attest with false certificates num
 * @tc.type: FUNC
 */
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest025, TestSize.Level0)
{
    struct HksParamSet *paramSet = nullptr;
    HksCertChain *certChain = nullptr;
    HKS_LOG_I("enter HksAttestKeyNonIdsTest025");
    int32_t ret = TestGenerateKey(&g_keyAlias, HKS_PADDING_PSS);
    ASSERT_EQ(ret, HKS_SUCCESS);
    struct HksParam g_commonParams[] = {
        { .tag = HKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, .blob = g_secInfo },
        { .tag = HKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge },
        { .tag = HKS_TAG_ATTESTATION_ID_VERSION_INFO, .blob = g_version },
        { .tag = HKS_TAG_ATTESTATION_ID_ALIAS, .blob = g_keyAlias },
        { .tag = HKS_TAG_ATTESTATION_BASE64, .boolParam = true },
    };
    GenerateParamSet(&paramSet, g_commonParams, sizeof(g_commonParams) / sizeof(g_commonParams[0]));
    const struct HksTestCertChain certParam = { true, true, true, g_size };
 
    (void)ConstructDataToCertChainWithCount(&certChain, &certParam, CERT_COUNT_5);
    ret = ValidateCertChainTest(certChain, g_commonParams, NON_IDS_PARAM);
    ASSERT_EQ(ret, HKS_ERROR_INVALID_ARGUMENT);
 
    const struct OH_Huks_Blob oh_g_keyAlias = { sizeof(ALIAS), (uint8_t *)ALIAS };
    struct HksParamSet *newParamSet = nullptr;
    ret = ConstructNewParamSet(paramSet, &newParamSet);
    ret = OH_Huks_AnonAttestKeyItem(&oh_g_keyAlias, (struct OH_Huks_ParamSet *) newParamSet,
        (struct OH_Huks_CertChain *) certChain).errorCode;
    if (ret != HKS_SUCCESS) {
        HKS_LOG_I("OH_Huks_AnonAttestKeyItem fail, ret is %" LOG_PUBLIC "d!", ret);
    }

    FreeCertChain(&certChain, certChain->certsCount);
    HksFreeParamSet(&newParamSet);
    HksFreeParamSet(&paramSet);
    ret = HksDeleteKeyForDe(&g_keyAlias, NULL);
    ASSERT_EQ(ret, HKS_SUCCESS);
}

#ifndef HKS_UNTRUSTED_RUNNING_ENV
HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest026, TestSize.Level0)
{
    HKS_LOG_E("enter HksAttestKeyNonIdsTest026");

    int32_t ret = HKS_ERROR_BAD_STATE;
    struct HksParamSet *paramSetOut = nullptr;
    ASSERT_EQ(HksInitParamSet(&paramSetOut), HKS_SUCCESS);
    paramSetOut->paramSetSize = sizeof(struct HksParamSet); /* paramSetOut size invalid */

    struct HksBlob certs[] = {
        { .data = cert1good, .size = sizeof(cert1good) },
        { .data = cert2good, .size = sizeof(cert2good) },
        { .data = cert3good, .size = sizeof(cert3good) },
        { .data = cert4good, .size = sizeof(cert4good) },
    };

    struct HksCertChain certChain = {
        .certs = certs,
        .certsCount = 4
    };

    ret = HksValidateCertChain(&certChain, paramSetOut);
    EXPECT_EQ(ret, HKS_SUCCESS) << "HksValidateCertChain, ret = " << ret;
    HksFreeParamSet(&paramSetOut);
    HKS_LOG_E("leave HksAttestKeyNonIdsTest026");
}
#endif

HWTEST_F(HksAttestKeyNonIdsTest, HksAttestKeyNonIdsTest027, TestSize.Level0)
{
    HKS_LOG_I("enter HksAttestKeyNonIdsTest027");
    struct HksParamSet *paramSetOut = nullptr;
    ASSERT_EQ(HksInitParamSet(&paramSetOut), HKS_SUCCESS);
    paramSetOut->paramSetSize = sizeof(struct HksParamSet); /* paramSetOut size invalid */

    struct HksBlob certs[] = {
        { .data = cert1, .size = sizeof(cert1) },
        { .data = cert2, .size = sizeof(cert2) },
        { .data = cert3, .size = sizeof(cert3) },
        { .data = cert4, .size = sizeof(cert4) },
    };

    struct HksCertChain certChain = {
        .certs = certs,
        .certsCount = 4
    };

    int32_t ret = HksValidateCertChain(&certChain, paramSetOut);
    EXPECT_EQ(ret, HKS_ERROR_VERIFICATION_FAILED) << "HksValidateCertChain failed, ret = " << ret;
    HksFreeParamSet(&paramSetOut);
    HKS_LOG_I("leave HksAttestKeyNonIdsTest027");
}

}
